Jump to content

Change compose output to alphabetical sequence


Recommended Posts

Why not just sort the data before it gets to FusionPro? That would save you from reworking your template code.


But if you really want FusionPro to do it, it's possible. You'll have to link to your primary data file as an external data file, push all of the records into an array and then sort the records based on the "Last Name" field. From there, you'll have to reference the array to determine the correct record number to use and read it from the external data file.


JavaScript Globals

ex = null;
data = [];
function ExField(name) {
 return ex.GetFieldValue(data[FusionPro.Composition.inputRecordNumber - 1], name);


ex = new ExternalDataFileEx(PrimaryInputFile(), ',');
for (var i=1; i <= ex.recordCount; i++)
       name: ex.GetFieldValue(i, 'Last Name'), 
       rec: i 

data = data.sort(function(a,b){ 
   return a.name < b.name ? -1 : a.name > b.name ? 1 : 0; 
}).map(function(s){ return s.rec });


Note, that you'll have to replace any use of the "Field" function in your rules with "ExField."

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...