rgreenidge Posted May 6, 2011 Share Posted May 6, 2011 Is it possible to compose a record that will display the field names from the data, so that we can verify that the fields have been placed in the correct spots. Thanks, Richard. Link to comment Share on other sites More sharing options...
Dan Korn Posted May 6, 2011 Share Posted May 6, 2011 Sure, you can do something like this: var result = "Fields:"; for (var i in FusionPro.Fields) result += "\n" + i; return result; And if you also want to see the field values for the current record: var result = "Fields:"; for (var i in FusionPro.Fields) result += "\n" + i + "=" + FusionPro.Fields[i]; return result; Link to comment Share on other sites More sharing options...
rgreenidge Posted May 6, 2011 Author Share Posted May 6, 2011 Hi Dan, thanks for the quick reply. What type rule would I need to use. I tried placing the text in a Callback Rule but this did not work. Thanks, Richard. Link to comment Share on other sites More sharing options...
Dan Korn Posted May 6, 2011 Share Posted May 6, 2011 Do this in a regular Text JavaScript rule, not a callback rule. Link to comment Share on other sites More sharing options...
rgreenidge Posted May 6, 2011 Author Share Posted May 6, 2011 Sorry, Dan I realized from your replies that I was not specific in my explanation. I would like to return the field names in the positions they appear in the template. I hope I have made it a little clearer. I appreciate your patience. Thanks, Richard. Link to comment Share on other sites More sharing options...
mcmahand Posted May 6, 2011 Share Posted May 6, 2011 I had been wondering how to display the variable names in place as well. This variation on Dan's code seems to work (placed in the OnRecordStart callback): for (var i in FusionPro.Fields) FusionPro.Composition.AddVariable(i, i); But only variables placed directly in the text frame will substitute (not fields used in a rule). Link to comment Share on other sites More sharing options...
Dan Korn Posted May 6, 2011 Share Posted May 6, 2011 Sorry, Dan I realized from your replies that I was not specific in my explanation. I would like to return the field names in the positions they appear in the template. Oh, if you want to do that, just set your input source to "None", and you'll get each field name in curly braces wherever it's referenced in a text frame. Link to comment Share on other sites More sharing options...
Dan Korn Posted May 6, 2011 Share Posted May 6, 2011 I had been wondering how to display the variable names in place as well. This variation on Dan's code seems to work (placed in the OnRecordStart callback): for (var i in FusionPro.Fields) FusionPro.Composition.AddVariable(i, i); But only variables placed directly in the text frame will substitute (not fields used in a rule). Right, that AddVariable function is a member of the Composition object, so it injects the variables into the composition engine's variable list at a lower level than the rules engine. So it has no effect on other rules which may be calling the Field function. If you want to change what the Field function does, you can just redefine it in the JavaScript Globals, like so: function Field(name) { return name; }Of course, I have to issue a huge caveat with this strategy of redefining FusionPro's own built-in functions, which is that it's not really supported, and it may break your job in unexpected ways. In other words, don't blame me if it makes your computer blow up. That said, though, have fun! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.