PDA

View Full Version : External data Cross Reference and Output


rgreenidge
August 26th, 2013, 07:28 AM
I am trying to create a rule that Cross references to fields, if they match I want to output that record and it's repeat qty. I would also like to have a slipsheet between records, that prints some of the fields from the extrenal file ie: the Shipping day. So far I have tried to use the following for the External data part from the example file you posted, but it does not seem to be linking to the external data. I am sure there maybe parts that are not needed to want I am trying to accomplish

Placed in OnJobStart Rule:
//Link to the external data file.
//The '\t' is used to indicate TAB delimited data in this external data file
externalDF = new ExternalDataFileEx('Fri Kit 36.txt', '\t');

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

Separate Rule Created:

//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)
{
Rule("OnJobStart");
}


//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
//file.
//
//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, 'Store_Num') == Field("Store_Num"))
{
//Check to see Ship Day. If it is, let's format it differently
if (externalDF.GetFieldValue(recordWalker, 'day') == 'Friday')
{
returnStr += 'Store_Num' + externalDF.GetFieldValue(recordWalker, 'Store') + '</b>';

}
else //OK - so this is a normal product - not a Tax item
{
returnStr
}
}
}


return returnStr;

Thanks in advance.
Richard.

Dan Korn
August 27th, 2013, 09:54 AM
So far I have tried to use the following for the External data part from the example file you posted, but it does not seem to be linking to the external data. I am sure there maybe parts that are not needed to want I am trying to accomplish
It's hard to know what's going on without more information. What exactly do you mean by, "it does not seem to be linking to the external data?" Do you get an error message? Is it getting the wrong data? Is it not getting any data at all? If you could post the external data file, or better yet, the whole template, or at least enough of it to show the issue, that would be helpful.