Jump to content

How to formulate a rule…


Gerard

Recommended Posts

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...