ricky10ss Posted December 7, 2016 Share Posted December 7, 2016 Was wondering is there a way to change the composed output file to sort alphabetically by the last name which is a field in the csv file instead of the sequence provide in the csv? I would be using FP Imposer to impose. Quote Link to comment Share on other sites More sharing options...
step Posted December 7, 2016 Share Posted December 7, 2016 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); } OnJobStart ex = new ExternalDataFileEx(PrimaryInputFile(), ','); for (var i=1; i <= ex.recordCount; i++) data.push({ 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." 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.