PDA

View Full Version : How to formulate a rule…

Gerard
February 7th, 2013, 04:05 AM
Hi,
I try to write a rule but nothing seems to work properly…

In a 8 pages document, we use 2 choices successively ("in cascade") that validate the creation of a 2 or a 3 pages final downloadable document.

first choice :
Option 1 eliminate pages 1 / 2 / 3 / 4 (pages 5 / 6 / 7 / 8 are used)
Option 2 eliminate pages 5 / 6 (pages 1 / 2 / 3 / 4 / 7 / 8 are used)

Then choice 2 comes to eliminate half of the resulting pages :
First case : page 5 / 7 (pages 8 / 6 are used) or 6 / 8 (pages 1 / 3 are used) then we have our 2 pages final document.

Second case : 1 / 3 / 7 (pages 2 / 4 / 8 are used) or 2 / 4 / 8 (pages 1 / 3 / 7 are used) then we have our 3 pages final document.

I tried this :
----------------------------------------------------------------------------------------
if (Field("flux")=="Bi flux")
{
FusionPro.Composition.SetBodyPageUsage("Corps 1", false);
}
{
FusionPro.Composition.SetBodyPageUsage("Corps 2", false);
}
{
FusionPro.Composition.SetBodyPageUsage("Corps 3", false);
}
{
FusionPro.Composition.SetBodyPageUsage("Corps 4", false);
}
if (Field("flux")=="Tri flux")
{
FusionPro.Composition.SetBodyPageUsage("Corps 5", false);
}
{
FusionPro.Composition.SetBodyPageUsage("Corps 6", false);
}
if (Field("logo-2")=="")
{
FusionPro.Composition.SetBodyPageUsage("Corps 2", false);
}
{
FusionPro.Composition.SetBodyPageUsage("Corps 4", false);
} {
FusionPro.Composition.SetBodyPageUsage("Corps 6", false);
}
{
FusionPro.Composition.SetBodyPageUsage("Corps 8", false);
}
-----------------------------------------------------------------------------
But when trying to validate the rule, I have the error message "Function returns no value" or "No value returned" (I use a french version of FusionPro…)

If someone could tell where I am wrong (or so stupid !:D), I would be grateful.
Gerard.

johnw
February 7th, 2013, 05:31 AM
Hi Gerard,

I always have to write a conditional statement for each combination of values in order to make something like this work. I also have to turn on(true) and off(false) the necessary pages for each condition. Like this:

if (Field("Flux")=="bi-flux" && (Field("Logo")=="a"))
{
FusionPro.Composition.SetBodyPageUsage("Corps 1", false);
FusionPro.Composition.SetBodyPageUsage("Corps 2", false);
FusionPro.Composition.SetBodyPageUsage("Corps 3", false);
FusionPro.Composition.SetBodyPageUsage("Corps 4", false);
FusionPro.Composition.SetBodyPageUsage("Corps 5", true);
FusionPro.Composition.SetBodyPageUsage("Corps 6", false);
FusionPro.Composition.SetBodyPageUsage("Corps 7", true);
FusionPro.Composition.SetBodyPageUsage("Corps 8", false);
}

For each additional condition, use "else if". The problem with this is that the rule gets really long if you have a lot of conditions.

I'm sure there's a simpler way to do this but I haven't figured it out yet. Good Luck!

Dan Korn
February 7th, 2013, 06:50 AM
But when trying to validate the rule, I have the error message "Function returns no value" or "No value returned" (I use a french version of FusionPro…)

If someone could tell where I am wrong (or so stupid !:D), I would be grateful.
The FusionPro.Composition.SetBodyPageUsage function can be called only from the OnRecordStart callback rule.

Gerard
February 7th, 2013, 10:01 PM
Thank you Johnw ! I will try your formulation !
Dan, I re entered my rule in an "On record start" and I have no more error message.
Thank you all !

Gerard
February 8th, 2013, 03:29 AM
I have another (little) question.
In my example, one case is if a field remains empty (typed ""). Is there a way to type "if the field is NOT empty ?
I'm searching but I feel I'm the only one concerned by a non empty field…
Gerard.

Dan Korn
February 8th, 2013, 05:29 AM
I have another (little) question.
In my example, one case is if a field remains empty (typed ""). Is there a way to type "if the field is NOT empty ?
I'm searching but I feel I'm the only one concerned by a non empty field…
Gerard.
if (Field("YourFieldName") != "")
{
// do something if the field is non-empty
}
Or, equivalently:
if (Field("YourFieldName"))
{
// do something if the field is non-empty
}

Gerard
February 8th, 2013, 07:13 AM
Thank you Dan, I think it will be really helpful ! :)
G.