PDA

View Full Version : JavaScript rule using Record Count


kleland
December 9th, 2008, 08:19 AM
Hi, any assistance would be appreciated. I'm trying to write a rule for a variable web postcard using OnRecordStart that will generate a page with indicia OR one with no indicia based on the record count of the variable file being uploaded. I have created and named my 2 pages using Manage Pages and written my rule. My result is always the same with the rule as written it gives me the page with an indicia regardless of the record count. If anyone can show me how to write this rule, it would be appreciated. Thanks!

I'm using MAC OS 10.4.10, Acrobat 7, FP Desktop Version 4.2P1d


RULE as it stands now:



(ExternalDataFileEx.recordCount == '')
FusionPro.Composition.composeThisRecord = false;

if (ExternalDataFileEx.recordCount <= 199)

{
FusionPro.Composition.SetBodyPageUsage('Back_NI', true);
FusionPro.Composition.SetBodyPageUsage('Back_Indic ia', false);
}

else

{
FusionPro.Composition.SetBodyPageUsage('Back_NI', false);
FusionPro.Composition.SetBodyPageUsage('Back_Indic ia', true);
}

MHardee
December 9th, 2008, 08:58 AM
Hi, any assistance would be appreciated. I'm trying to write a rule for a variable web postcard using OnRecordStart that will generate a page with indicia OR one with no indicia based on the record count of the variable file being uploaded. I have created and named my 2 pages using Manage Pages and written my rule. My result is always the same with the rule as written it gives me the page with an indicia regardless of the record count. If anyone can show me how to write this rule, it would be appreciated. Thanks!

I'm using MAC OS 10.4.10, Acrobat 7, FP Desktop Version 4.2P1d


RULE as it stands now:



(ExternalDataFileEx.recordCount == '')
FusionPro.Composition.composeThisRecord = false;

if (ExternalDataFileEx.recordCount <= 199)

{
FusionPro.Composition.SetBodyPageUsage('Back_NI', true);
FusionPro.Composition.SetBodyPageUsage('Back_Indic ia', false);
}

else

{
FusionPro.Composition.SetBodyPageUsage('Back_NI', false);
FusionPro.Composition.SetBodyPageUsage('Back_Indic ia', true);
}


I find you just about have to set all pages to UNused in the page manager and turn ON only the pages you need via rule..

So, your:\\FusionPro.Composition.SetBodyPageUsage('Bac k_Indicia', false);Also, the rules loop UNTIL a condition is found to be true and THEN stops processing..

HTH..

kleland
December 9th, 2008, 09:06 AM
Thanks, but I'm not sure I understand. My body pages are currently UNused and the condition I'm trying to write is that if the record count in less than or equal to 199, use No Indicia page, else use Indicia page.

pklingler
December 12th, 2008, 06:55 AM
Your page usage rule looks correct, but unless there's more to your code at the beginning, the problem is how you're getting the recordcount.

Look at the ExternalDataFileEx object in the Rules Guide (page 84 in my version) for more details.

Try something like this:


YourDataFile = new ExternalDataFileEx('C:\\Printable\\data.csv', ',');
if (YourDataFile.recordCount <=199)
{ FusionPro.Composition.SetBodyPageUsage('Back_NI', true); }
else
{ FusionPro.Composition.SetBodyPageUsage('Back_Indic ia', true); }


You'll have to update the path to your data file and delimiter (in red), and this works with both pages set to unused, only turning on the one that's needed depending on the count.

kleland
December 12th, 2008, 01:08 PM
Thanks Paul! I'll try it. I think I have an old version of the Rules Guide...