Jump to content

Output to multiple files - stay unique


Recommended Posts

I'm outputting to multiple files based on a Data field "AccountNo".


Problem is I can have 2 or more people with the same accountNo that live in the same location.


So is there a way to keep it unique and not overwrite itself.


Maybe add a "_1 or _2 or _3" depending on how many times the same account number comes up.


FusionPro.Composition.outputFileName = Field("AccountNo") + ".pdf";

Link to comment
Share on other sites

You could do it by tracking how many times each account number has been used by adding them to a global object:

JavaScript Globals

var accounts = {};



var FP = FusionPro.Composition;
var accountNumber = Field('AccountNo');
if (!accounts[accountNumber]) {
 accounts[accountNumber] = 1;
} else {
 accountNumber += '_' + ++accounts[accountNumber];
FP.OpenNewOutputFile(accountNumber + '.' + FP.outputFormatExtension);

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...