Jump to content

Project / Need Creative Solution


Recommended Posts

We are trying to figure out how to process a mailing with variable info, but we're not sure how best to tackle this unique job.


A letter will be sent out to physicians. On the back, there will be a list of patients unique to that physician alone. So each letter will have "Dear Dr. <<NAME>>", and the back will have unique patient names on each letter. If we receive a data file with each patient as a unique record, and their corresponding physician designated in a field within each record, how do we create a rule that: 1) allows for a varying number of names on each piece (could be two names, could be ten), and 2) draws those names in aggregate for each physician. I see so many logistical headwinds with this job, from the data segregation to the actual rules and logic.


Anybody have any thoughts or suggestions? Any help greatly appreciated.

Link to comment
Share on other sites

Sounds like you would want a separate data file with a single record for each doctor to use as your primary data file. Then you could link to the data file you describe above as an external data object and add code that would "collect" all the patient records which have the matching doctor name (doctor's name would be primary key between data files) in an array. Then you just spit out the values of the array in a text rule.
Link to comment
Share on other sites

:eek: Is there a button for that?


I really appreciate the response. But it sounds more sophisticated than our current skill sets. Are you able to point me to any sort of resource pertaining to your explanation? I think I follow what you're saying, but don't specifically know how to implement the solution. If you could point me to something, we can probably start to piece the solution together.


Again, than you so much for your help.

Link to comment
Share on other sites

  • 3 weeks later...

This job was put on hiatus, and now has come back to us for production. I've looked over the posts for "External Data", but am confused by the information. Does anybody know if I can create a rule using the rule editor in FP to connect an external data file, or do I have to know how to write script for that? If the latter, is there anybody willing to spend a few minutes with me on the phone to walk through setting this up? I have decent data skills, so it won't be like the help desk working with the guy who forgot to plug in his computer. We have a couple more of these jobs for this customer coming down the pike in the next month.


Or . . . can anybody point me to a detailed exampled of how to set up an external reference? I don't know JS keywords, commands, etc.


Thank you to anybody that's willing to go some extra steps with us!

Link to comment
Share on other sites

The example Eric pointed you appears to be on par with what you are looking to do. Download the sample and look at the rules.


There are two parts to the process:

1. You will need a On Job Start Rule to reference the External Data File

2. A text rule to apply the text on the piece.


Step 1:

Create a On Job Start Rule to reference the external file.

FusionPro>Edit Rules>New>Callback(Rule Type)>On Job Start


//Link to the external data file.  
//The '\t' is used to indicate TAB delimited data in this external data file
externalDF = new ExternalDataFileEx('secondary-input-file_Purchases.txt', '\t');

if(externalDF.valid != true)
   Print('Failed to link to the external data file in OnJobStart');



Step 2:

Create a empty text rule to reference the external file.

FusionPro>Edit Rules>New>Text(Rule Type)>Empty Rule


//Create an empty variable that will be populated with a 
//string of text that lists the customer's purchases
returnStr = '';

//The following if statement will detect if we are currently in preview
//mode or editing this rule (versus composing output).  If so, the script
//will manually call the OnJobStart rule so the link to the external 
//data file can be established.  OnJobStart is called automatically when
//a full composition is run.
if(FusionPro.Composition.isPreview == true || FusionPro.inValidation == true)

//Get a count of the total number of records in the external data file
numRecsExtDF = externalDF.recordCount;

//Now, loop through all records in the external data file and 
//find the records that belong to the customer.  This is done
//by comparing the value of "CustomerID" from the main input
//data file to the value of the "CID" field in the external data
//Note that in this example, there can be multiple records in the 
//external data file for each customer which is why we are going to
//look at every record in the external data file.

for (recordWalker=1; recordWalker <= numRecsExtDF; recordWalker++)
   //Compare the value of the CID field in the current record
   //we are looking at in the external data file to the value
   //of the CustomerID field in the main data file.
   if (externalDF.GetFieldValue(recordWalker, 'CID') == Field("CustomerID"))
       //Check to see if this is a TAX item.  If it is, let's format it differently
       if (externalDF.GetFieldValue(recordWalker, 'Product-Purchased') == 'Tax')
           returnStr += '<br><b>Total Tax - ' + externalDF.GetFieldValue(recordWalker, 'Price') + '</b>';

       else //OK - so this is a normal product - not a Tax item
           returnStr += externalDF.GetFieldValue(recordWalker, 'Product-Purchased');
           returnStr += ' - ';
           returnStr += externalDF.GetFieldValue(recordWalker, 'Price');
           returnStr += '<br>';

return returnStr;


Read the notes in the JaveScript, edit fields, and formatting as needed. The code above is directly from the example referenced in the previos post by Eric.

Link to comment
Share on other sites

Not sure the proper protocol, but we wanted to give a public BIG THANKS to Chad for his "extended" help with this project. Got us through the job, and gave us an education along the way! Problem solved!
Link to comment
Share on other sites


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

  • Create New...