karlaeprintingedge.com Posted October 29, 2009 Share Posted October 29, 2009 If my data fields "Pr1" and "Pr2" are the same, or if "Pr2" is empty, it needs to read "I". If the two fields are different, it should pull the info from the external file. I have attached what I have so far, in a text file. Any help would be greatly appreciated.subagentrule.txt Link to comment Share on other sites More sharing options...
Dan Korn Posted October 29, 2009 Share Posted October 29, 2009 If my data fields "Pr1" and "Pr2" are the same, or if "Pr2" is empty, it needs to read "I". What is "it" in the sentence above? The result of a rule? If so, that part of the logic seems simple enough: if ((Field("Pr1") == Field("Pr2")) || !Field("Pr2")) return "I"; //else // (do something else here...)If the two fields are different, it should pull the info from the external file. If what you already have so far is working, then just put those two lines I wrote above at the top, and your existing logic should still work. I have attached what I have so far, in a text file. Any help would be greatly appreciated. Is that an RTF file? It looks like gibberish when I open it in Notepad. If you're trying to post some JavaScript code, just include it in your post directly. If you want, you can click on "Go Advanced", then select the code and click the "#" button in the Editor to put it in a nice "Code" block like in my posts. Link to comment Share on other sites More sharing options...
karlaeprintingedge.com Posted October 30, 2009 Author Share Posted October 30, 2009 Thanks for the reply. One more question if you don't mind. Where in the attached rule would that logic go? Link to comment Share on other sites More sharing options...
karlaeprintingedge.com Posted November 2, 2009 Author Share Posted November 2, 2009 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 Pr2 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, 'Who Code') == Field("Pr2")) { //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 += '<b>' + externalDF.GetFieldValue(recordWalker, 'Address')+'</b>'; returnStr += '<br>'; returnStr += externalDF.GetFieldValue(recordWalker, 'City'); returnStr += ' '; returnStr += externalDF.GetFieldValue(recordWalker, 'Zip'); returnStr += '<br>'; } } } return returnStr; Link to comment Share on other sites More sharing options...
karlaeprintingedge.com Posted November 3, 2009 Author Share Posted November 3, 2009 I have added the logic I received from Dan earlier. I'm still missing something. Now the rule is pulling every name from my external file. It should only be pulling one name per one record. This what I have now. //Create an empty variable that will be populated with a //string of text that lists the Agents 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 "Pr2" from the main input //data file to the value of the "Who Code" field in the external data //file. for (recordWalker=1; recordWalker <= numRecsExtDF; recordWalker++) { //Compare the value of the Pr2 field in the current record //we are looking at in the external data file to the value //of the Who Code field in the main data file. //I need to compare fields Pr2 and Pr1. //to see if they are the same then use "I" or if //Pr2 is blank then use Pr1 if ((Field("Pr1") == Field("Pr2")) || !Field("Pr2")) { return "I"; } if(externalDF.GetFieldValue(recordWalker, 'Who Code') == Field("Pr2")); { returnStr += '<b>' + externalDF.GetFieldValue(recordWalker, 'Employee Name')+'</b>'; returnStr += '<br>'; } } return returnStr; Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.