Jump to content

Composing a record that will display the field names


Recommended Posts

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

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...