#1
|
|||
|
|||
![]()
Good afternoon!
I am having trouble with my first external data file and hoping someone can help. What I am needing to do is simply call office names from a data file and it isn't working. I've attached my rules below, any help is greatly appreciated! // This is in "OnJobStart" Code:
XDF = new ExternalDataFileEx("MasterDeparmentsListFinal.txt"); //MasterDepartmentsListFinal.txt is housed in the same folder as the master PDF file. return XDF.valid; Code:
if (FusionPro.inValidation) Rule("OnJobStart"); primaryline1 = ""; for (i = 1; i < XDF.recordCount+1; i++) { Department = XDF.GetFieldValue(i, 2); { if (Field("Department") == Department) { var primaryline1 = XDF.GetFieldValue(i, 3); } } } return primaryline1; Code:
Template Sequence Full Name PrimaryLine1 PrimaryLine2 Secondary Line1 1line 1 Division of Humanities Division of Humanities 1line 2 Art and Art History Department Art and Art History Department 1line 3 Chinese and Japanese Department Chinese and Japanese Department 1line 4 Classics Department Classics Department 1line 5 English Department English Department 1line 6 French and Arabic Department French and Arabic Department 1line 7 German Department German Department 1line 8 Music Department Music Department 1line 9 Philosophy Department Philosophy Department 1line 10 Religious Studies Department Religious Studies Department 1line 11 Russian Department Russian Department 1line 12 Spanish Department Spanish Department 1line 13 Theatre and Dance Department Theatre and Dance Department 1line 14 Division of Science Division of Science 1line 15 Biological Chemistry Department Biological Chemistry Department |
#2
|
|||||
|
|||||
![]() Quote:
Code:
var XDF = new ExternalDataFileEx("MasterDeparmentsListFinal.txt"); var found = XDF.FindRecord("Full Name", Field("Department")); return XDF.GetFieldValue(found, "PrimaryLine1"); Code:
var XDF = new ExternalDataFileEx("MasterDeparmentsListFinal.txt"); var mainDepartmentName = Trim(ToLower(Field("Department"))); var found = -1; for (var i = 1; i <= XDF.recordCount && found < 0; i++) { var XDFDepartmentName = Trim(ToLower(XDF.GetFieldValue(i, "Full Name"))); if (XDFDepartmentName == mainDepartmentName) found = i; } return XDF.GetFieldValue(found, "PrimaryLine1"); Quote:
Quote:
Quote:
Anyway, if you want to do this all at once, without writing three separate rules to return the three different values, you can use "variable injection", by moving the code into OnRecordStart, and replacing the last "return" line with this: Code:
if (found > 0) { FusionPro.Composition.AddVariable("PrimaryLine1", XDF.GetFieldValue(found, "PrimaryLine1")); FusionPro.Composition.AddVariable("PrimaryLine2", XDF.GetFieldValue(found, "PrimaryLine2")); FusionPro.Composition.AddVariable("Secondary Line1", XDF.GetFieldValue(found, "Secondary Line1")); } Though, this can be generalized as well, to add all the fields from the XDF as text variables, like so: Code:
if (found > 0) { for (var i = 0; i < XDF.fieldCount; i++) FusionPro.Composition.AddVariable(XDF.GetFieldValue(0, i), XDF.GetFieldValue(found, i)); } Quote:
Code:
FusionPro.Composition.SetBodyPageUsage(XDF.GetFieldValue(found, "Template"), true); Code:
var XDF = new ExternalDataFileEx("MasterDeparmentsListFinal.txt"); var mainDepartmentName = Trim(ToLower(Field("Department"))); var found = -1; for (var i = 1; i <= XDF.recordCount && found < 0; i++) { var XDFDepartmentName = Trim(ToLower(XDF.GetFieldValue(i, "Full Name"))); if (XDFDepartmentName == mainDepartmentName) found = i; } if (found > 0) { for (var i = 0; i < XDF.fieldCount; i++) FusionPro.Composition.AddVariable(XDF.GetFieldValue(0, i), XDF.GetFieldValue(found, i)); } FusionPro.Composition.SetBodyPageUsage(XDF.GetFieldValue(found, "Template"), true); Code:
var XDF = new ExternalDataFileEx("MasterDeparmentsListFinal.txt"); var found = XDF.FindRecord("Full Name", Field("Department")); if (found > 0) { for (var i = 0; i < XDF.fieldCount; i++) FusionPro.Composition.AddVariable(XDF.GetFieldValue(0, i), XDF.GetFieldValue(found, i)); } FusionPro.Composition.SetBodyPageUsage(XDF.GetFieldValue(found, "Template"), true);
__________________
Dan Korn FusionPro Developer / JavaScript Guru / Forum Moderator PTI Marketing Technologies | Printable | MarcomCentral I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com. Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs. This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data. Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages. Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance. Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support. How To Ask Questions The Smart Way The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript. Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5. return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)}); ![]() |
#3
|
|||
|
|||
![]()
Thanks Dan! I will dive in to this and see where I end up, your expertise is very much appreciated!
|
#4
|
|||
|
|||
![]()
Dropped the XDF in to indesign and it appears to be working like a charm, will update if I run in to any issues!
Thanks again so much! |
#5
|
|||
|
|||
![]()
Dan,
I really appreciate your detailed explanation. Your code is indicating that it is no longer necessary to define a delimiter, is that true? Quote:
Code:
new ExternalDataFileEx(Filename [,Delimiter OR Type] [,encoding OR Excel sheet])
__________________
Windows 10 - FusionPro 10.0.26; Acrobat DC; Steve Davenport Variable Communications |
#6
|
||||
|
||||
![]() Quote:
Quote:
For a flat-file XDF, you can also specify an encoding for the file in the third parameter, as you can for most other plain-text resources. So for instance, if your file is in Mac Roman encoding, you can specify that. If the encoding is not specified, then the same logic is used to determine the encoding for the primary data file, which is that if there's a UTF-8 or UTF-16 marker, the file will be considered to have Unicode encoding, and if not, it will be considered to have Latin-1 on encoding Windows or Mac Roman encoding on Mac.
__________________
Dan Korn FusionPro Developer / JavaScript Guru / Forum Moderator PTI Marketing Technologies | Printable | MarcomCentral I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com. Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs. This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data. Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages. Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance. Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support. How To Ask Questions The Smart Way The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript. Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5. return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)}); ![]() |
#7
|
|||
|
|||
![]()
Thank you, Dan!
This Forum is part of what makes PTI such a great product!
__________________
Windows 10 - FusionPro 10.0.26; Acrobat DC; Steve Davenport Variable Communications |
#8
|
||||
|
||||
![]()
Dan, thank you for the extended explanation of the XDF optional parameters (in addition to the rest of your response).
__________________
Brad Mather WestCamp |
#9
|
|||
|
|||
![]()
Follow up question on this. I am now needing to implement a rule on this template, that incorporates the "Change case selection of name field" to one of the XDF fields that are being pulled in to the template.
The problem that I am running in to, is when I write the rule to add the name field, it is giving me an error saying that the field doesn't exist (because it doesn't exist in the template, only in the XDF). Is there a way to write it in-line in the text box where the rule is to convert just that line to small caps? Below is the rule set that I currently have: My Rule Trying to convert "STPL1" field from my XDF to small caps: Quote:
Quote:
|
#10
|
||||
|
||||
![]()
I think all you need to do is change OnRecordStart to this:
Code:
var XDF = new ExternalDataFileEx("MasterDeparmentsListFinal.txt" ); var found = XDF.FindRecord("Full Name", Field("Department")); if (found > 0) { for (var i = 0; i < XDF.fieldCount; i++) FusionPro.Composition.AddVariable(XDF.GetFieldValue(0, i), XDF.GetFieldValue(found, i)); var STPL1_small = "<smallcap>" + TaggedTextFromRaw(XDF.GetFieldValue(found, "STPL1"))) + "</smallcap>"; FusionPro.Composition.AddVariable("STPL1", STPL1_small, true); } P.S. When posting code, first click the "Go Advanced" button, then use the # button for a Code block instead of a quote.
__________________
Dan Korn FusionPro Developer / JavaScript Guru / Forum Moderator PTI Marketing Technologies | Printable | MarcomCentral I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com. Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs. This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data. Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages. Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance. Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support. How To Ask Questions The Smart Way The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript. Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5. return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)}); ![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|