Jump to content

Indicia(graphic) changes based on record count


Recommended Posts

Posted

Basic two-sided postcard.

Indicia(graphic) changes based on record count.

 

lets say 499 records vs. 500 records.

499 records gets a single-piece indicia and the 500 gets a Presorted indicia.

 

Basic address list for the data.

I'm having a hard-time visualizing the rules.

 

Thanks!

Posted

RPatrick,

 

That one is basically an easy one...once someone shows you the trick to it. First of all you need to count the number of records in the data file in an OnJobStart rule. Then in that rule you set an indicator true or false based on a record limit that you set. I've even programmed one with a couple of different counts to determine whether or not it would have simply no indicia (<200), a straight First-Class indicia (200 - 499) or a Presorted Standard Class indicia (500 and over). Then in your graphic rule for the indicia you set whatever indicia you need based on this indiciator setting.

 

OnJobStart Rule

var myNewFile = new ExternalDataFileEx(FusionPro.Composition.inputFileName, ",");
fcIndicia = (myNewFile.recordCount > 199);
scIndicia = (myNewFile.recordCount > 499);

 

This rule opens the "comma delimited" file that is used during composition and pre-counts it with ".recordCount". Then it sets to "true" or "false" my two indicia indicators that I use in a graphic rule called "indiciaRule". It does slow down processing a bit since FP counts the file beforehand. Also, I'm sure that there are more efficient ways of doing this, but this rule works for us quite well.

 

indiciaRule

var countryCode = Trim(ToUpper(ReplaceSubstring(Field("Country"), ".", "")));
if ((countryCode == "US") || (countryCode == "USA") || (countryCode == ""))  {
   if (scIndicia)  {
       return new FusionProResource("../resources/PrsrtStd_hkm.pdf", "graphic", true);
   }
   else if (fcIndicia)  {
       return new FusionProResource("../resources/FirstClass_hkm.pdf", "graphic", true);
   }
   else  {
       return NullResource();
   }
}
else  {
   return NullResource();
}

 

As you can also see, I've also tied the indiciaRule to whether or not the country is part of the US or not. If it is a US address, then it will look at the scIndicia indicator first to see if the letter going to 500 or more addresses. If yes then it will return the Presorted Standard indicia (that I've stored in a folder called "resources") as the rule results. If the letter is going to more than 200 address but not more than 499, then a straight First Class indicia is passed as the result. The default is a NullResource() value to pass a blank for either less than 200 addresses or a non-US address. Typically a permit indicia is only allowable for US address, not foreign.

 

There is one caveat about this procedure that I need to warn you of and I think it's more a breach of Post Office protocol instead of anything that FusionPro should be responsible for. When there are less than 200 US address in your data file but this file also includes a few non-Us address bringing the total over 200 (i.e. 185 US with an extra 20 non-US) this procedure flunks out. The total for that data file would be 205 records making it eligable, by record count, for a First Class permit. However, I believe that the Post Office requires that the total must be all "eligable US address" for the indicia to be used. The total would only be 185 in my example and that would flunk Postal requirements. Know you data beforehand.

 

Good Luck.

Posted
RPatrick,

indiciaRule

var countryCode = Trim(ToUpper(ReplaceSubstring(Field("Country"), ".", "")));
if ((countryCode == "US") || (countryCode == "USA") || (countryCode == ""))  {
   if (scIndicia)  {
       return new FusionProResource("..[color=Red][b]/resources/PrsrtStd_hkm.pdf"[/b][/color], "graphic", true);
   }
   else if (fcIndicia)  {
       return new FusionProResource(".[b].[color=Red]/resources/FirstClass_hkm.pdf"[/color][/b], "graphic", true);
   }
   else  {
       return NullResource();
   }
}
else  {
   return NullResource();
}

 

D,

Thank you for your time and explanation. Overall, I think I'm understanding the whole logic. I did everything that you stated in the RULEs and Coding but I'm still getting an error. I tried to switch everything for a callout that would be associated with my art/naming convention. I think I may just be missing something in the RULE above and the path for the resource? I'm getting a indicia not defined in the 3rd line and I'm wondering if it's my path being the problem? I changed the name of the resource to match mine but it is still getting me the error. Anything I can check?

 

Thank You for you help:)

Ryan

Posted

Ryan,

 

I keep a folder for all variable graphic resources for a given project in a separate from my template. So if I need to change/update a resource and it affects several templates within that project, I just need to change the resource once and all templates will be using the newly updated file without the need to change each and every template each and every time. :D

 

However, if this is giving your machine a hang-over, you can always just make the indicia images graphic resources then refer to them as their resource name in the graphic rule instead of creating the resources on the fly as I did.

 

Try this instead...

var countryCode = Trim(ToUpper(ReplaceSubstring(Field("Country"), ".", "")));
if ((countryCode == "US") || (countryCode == "USA") || (countryCode == ""))  {
   if (scIndicia)  {
       return Resource("PrstdStd");
   }
   else if (fcIndicia)  {
       return Resource("FirstClass");
   }
   else  {
       return NullResource();
   }
}
else  {
   return NullResource();
}

 

Load the resources into FusionPro first, name them as indicated, then just point the rule to the correct resource.

 

Although, reading your post again, are you sure FP stated "the third line"? That might be referring to the "if statement" for scIndicia. You may need to make sure that the indicators you used in the OnJobStart rule match the ones in the graphic rule. Also make sure that you don't put a "var" in front of those indiciator names so they will become global variables.

 

Good luck.

 

David

Posted

D,

 

I'm getting no errors when I compose but its not switching to the correct graphic upon composing based on records. I tried 50, 200, and 501 and it's placing the scIndicia as the default. Could it be something now with the way I'm creating the recordcount or lack of?

 

screen shots.

Resources.jpg.2443aa2e80fe01ceca8e9cefebd729b4.jpg

 

Rules_1.thumb.jpg.eb5b680d28228202728167ae8cbcd193.jpg

 

Rules_global.jpg.07c22c0ed27a941bae0d66b6bab67830.jpg

 

Rules_indicia.jpg.70edd05ecfe6a3be11bda4b64fd2c6ab.jpg

Thanks!

Ryan

Posted
Sorry to but in here, but, isn't there an extra "{" at the end of line 2 that might cause this error?

 

Mark

 

Got it to work. Thanks for your help!

 

 

Thanks to DSweet as well for taking the time to help me figure this out!;)

Archived

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

×
×
  • Create New...