Jump to content

Creating a letter with specific names


Recommended Posts

So I have a project where I need to pull names and place them on a letter.


I have an Excel file with 3500+ names. Those names are sorted by office number of which there are 360 offices.


Sounds simple enough, right? Well here's where it gets a little difficult.

I have to place only the names of the people who are in the same office on the same letter. So when I'm done I need to have 360 letters and each letter can only have the names of the people who are in that specific office listed in a column.


My data looks something like this:


FIrst Name Last Name Office Number

Tom Jones 001

Lisa Jones 001

Billy Jones 001

Joe Smith 002

Howard Evans 002

Mark Swan 003

Tina Epstein 004

George Winston 004

Wallace Morgan 005


So how can I pull only the people from Office Number 001 and have their names listed (in a column) on one letter and then have only the people from Office Number 002 and list just them and so on and so on...


I am using Fusion Pro Desktop 7.2


Thank You!

Link to comment
Share on other sites

The thing to keep in mind is that FusionPro, by default, will compose your template (the letter) for each record in your data file. In your case it sounds like your data is set up in such a way that each record (row of data) is a person's name. So one letter would be created for Tom Jones, another separate letter would be created for Lisa Jones, and so on. Ideally, what you'd want is for each record to compose a letter for the Office Number.


So if reworking your data is an option, you could make it look like this:

"Office Number" "Workers"
"001"           "Tom Jones,Lisa Jones,Billy Jones"
"002"           "Joe Smith,Howard Evans"

On a side note, I can't help but feel like there is some serious nepotism at office 001.


Anyway, then for each record you could create your list by splitting the comma separated "workers" field and joining it with a line break:

return Field("Workers").split(",").join("<br>");


In terms of using an external data file, something like this might work for your particular case and wouldn't require you to rework your data:


FusionPro.Composition.compseAllRecords = false;
FusionPro.Composition.endRecordNumber = 360;


var ex = ExternalDataFileEx(FusionPro.Composition.inputFileName, ',');
var list = [];
for (var i = 1; i <= ex.recordCount; i++) {
 function ExField(name) { return ex.GetFieldValue(i, name); }
 var officeNumber = ExField("Office Number");
 if (officeNumber == FormatNumber('000', FusionPro.Composition.inputRecordNumber))
   list.push(ExField("First Name") + ' ' + ExField("Last Name"));
return list.join("<br>");


You might find that you need to add the path to your data file rather than FusionPro.Composition.inputFileName when trying to preview the template.

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