Jump to content

Print out error message and not compose


Tony Olivas

Recommended Posts

I am looking for a way to write an expression to error out when a certain field contains charcters too short or too long. Then print out the error message and not to compose file.

 

Something to the effect of:

 

if (Field("cert1") <= String("Character length"))

{

return "<span>" + String("Error out and print out ") + "</span>";

}

 

return "";

Link to comment
Share on other sites

Following Dan's suggestions, I came up with the following OnRecordStart rule:

var ShortString = 6; //shortest # characters in chosen field
var LongString = 24; //longest # characters in chosen field
var CheckField = Field("Company"); //chosen field
var CharCount = CheckField.length;

//if record contains short or long field, it will not be composed,
//and offending record will be noted in message log following composition
if ((CharCount >= LongString) || (CharCount <= ShortString)) {
   FusionPro.Composition.composeThisRecord = false;
   Print ("RECORD " + CurrentRecordNumber() + 
       " IS EITHER TOO SHORT OR TOO LONG!"); 
   }

In my test, 3 of 10 records did not compose, and my log following composition indicated which 3 records were left out. :)

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...