-Lisa- Posted October 1, 2014 Share Posted October 1, 2014 I need to call to an External Data file that will contain the data for an additional 40 fields - about 10 graphic fields and the balance text fields. Keeping in mind that I'm still a total JavaScript novice (just started a class though!!), is there a better way to call to this file than to create 40 different XDF rules? Quote Link to comment Share on other sites More sharing options...
David Miller Posted October 2, 2014 Share Posted October 2, 2014 (edited) Multiple fields in an external data file can be returned in a single JavaScript rule as demonstrated here. That said, having 40 fields in your XDF that need to be returned, it sounds like you need something more elaborate. Can you be more specific? Edited October 2, 2014 by David Miller Quote Link to comment Share on other sites More sharing options...
-Lisa- Posted October 2, 2014 Author Share Posted October 2, 2014 Thanks David! I'll take a look at that example now. The reason I'm doing this is because I need to sort a mailing file and my mail software does not allow me to map more than 15 "non-address" fields (fields that do not include mailing or address info). I want to use the sorted mail file as the master import file and then map to the XDF in order to pull in the remaining variable fields which include 10 variable images, and approximately 30 additional variable text areas. It's the only solution I can really think of without having to somehow merge the two data files together without risking compromising the data. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted October 2, 2014 Share Posted October 2, 2014 Typically, when you're using an external data file, you're doing something like building a table from multiple rows of data in the XDF, in which case you just call the GetFieldValue function for each field you need from each matching row, in a loop. However, in your case, it sounds like you are just getting values from a single matching external data file row, to use as text variables like fields from your main data file. One way to do this is to just call the GetFieldValue function for each field you need from the XDF, and build up blocks of text manually, like in the example from that other thread that David linked to. But I think what you want to do is to just be able to use the XDF fields directly as variables in the Text Editor, without having to build up all of the text in JavaScript or having to create a rule for each of the XDF fields. Fortunately, there's a handy feature called variable injection which can do exactly this, with the FusionPro.Composition.AddVariable function. You can call this function from OnRecordStart to set up a variable that you can call out in a text frame, just like the result of a rule. And you can call it multiple times to inject multiple variables, without having to create a separate rule for each one. So you can do something like this in OnRecordStart: // XDF loaded in OnJobStart if (FusionPro.inValidation) Rule("OnJobStart"); // Some logic to find a matching row in the XDF. var r = XDF.FindRecord("KeyField", Field("KeyFieldInMainData")); if (r < 1) throw("Unable to find matching row in External Data!"); for (var i = 0; i < XDF.recordCount; i++) FusionPro.Composition.AddVariable(XDF.GetFieldValue(r, i)); Quote Link to comment Share on other sites More sharing options...
David Miller Posted October 4, 2014 Share Posted October 4, 2014 But I think what you want to do is to just be able to use the XDF fields directly as variables in the Text Editor, without having to build up all of the text in JavaScript or having to create a rule for each of the XDF fields. Very cool. Wasn't aware of this. Could be much more efficient than what I'm doing. But, I'm not seeing the XDF fields appear in the Text Editor. No rush, but, any hints as to what I'm missing? Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted October 6, 2014 Share Posted October 6, 2014 Very cool. Wasn't aware of this. Could be much more efficient than what I'm doing. But, I'm not seeing the XDF fields appear in the Text Editor. No rush, but, any hints as to what I'm missing? The variable names injected at composition time with FusionPro.Composition.AddVariable don't appear in the Variables drop-down list in the Text Editor at design time. You need to type the name of the variable into the combo box and click Insert. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.