Jump to content

OnRecordStart Execution


Recommended Posts

Hello,

 

I am a newbie will little Javascript training. I am setting up a template that has two pages; one being a welcome and thank you letter and the second being a material request. The document only needs to be printed if there are actual requests in variables 1-14. If one of those fields are populated the document will be printed.

 

Upon composing all records are being composed, instead of just the records with material requests.

 

 

if(Field("VARIABLE1") || Field("VARIABLE2") || Field("VARIABLE3") || Field("VARIABLE4") || Field("VARIABLE5") || Field("VARIABLE6") ||Field("VARIABLE7")||("VARIABLE8") || Field("VARIABLE9") || Field("VARIABLE10") || Field("VARIABLE11") || Field("VARIABLE12") || Field("VARIABLE13") ||Field("VARIABLE14")!="")

 

FusionPro.Composition.ComposeThisRecord = true

 

else

 

if(Field("VARIABLE1") || Field("VARIABLE2") || Field("VARIABLE3") || Field("VARIABLE4") || Field("VARIABLE5") || Field("VARIABLE6") ||Field("VARIABLE7")||("VARIABLE8") || Field("VARIABLE9") || Field("VARIABLE10") || Field("VARIABLE11") || Field("VARIABLE12") || Field("VARIABLE13") ||Field("VARIABLE14")=="")

 

FusionPro.Composition.ComposeThisRecord = false;

Link to comment
Share on other sites

On your VARIABLE8 you're missing the Field part. Also, I'm not sure if it might have slipped your mind, but in your if statement there needs to be a condition on each pair. So, just having the == "" on the last pair doesn't apply to all of them. But, if you're just looking to see if the field contains anything then you're ok, unless those fields might include a 0. Also, it's composeThisRecord and not ComposeThisRecord. You don't really need the else statement either.

 

Might also just be personal preference, but I'm not a fan of the multiple if checks. But, here is how I would do it.

 

var arr = [
Field("VARIABLE1"), 
Field("VARIABLE2"), 
Field("VARIABLE3"), 
Field("VARIABLE4"), 
Field("VARIABLE5"), 
Field("VARIABLE6"),
Field("VARIABLE7"),
Field("VARIABLE8"),
Field("VARIABLE9"),
Field("VARIABLE10"),
Field("VARIABLE11"),
Field("VARIABLE12"),
Field("VARIABLE13"),
Field("VARIABLE14")
];

var combined = arr.filter(String).join("");

if(combined === ""){
 FusionPro.Composition.composeThisRecord = false;
}

Link to comment
Share on other sites

FusionPro.Composition.composeThisRecord = false; // skip if no content
for (var i = 1; i <= 14; i++)
{
   if (Field("VARIABLE" + i) // if Field("VARIABLE1") etc. is not empty
       FusionPro.Composition.composeThisRecord = true;
}

- or -

FusionPro.Composition.composeThisRecord = false; // skip if no content
for (var i = 1; i <= 14; i++)
{
   // if Field("VARIABLE1") etc. is not empty, compose the record
   FusionPro.Composition.composeThisRecord = Field("VARIABLE" + i) != "";
}

Link to comment
Share on other sites

  • 2 months later...

I am trying to use onrecordstart to only compose LA,NJ & MS.

 

if(Field("ST")=="LA")

FusionPro.Composition.composeThisRecord = true;

if(Field("ST")=="MS")

FusionPro.Composition.composeThisRecord = true;

if(Field("ST")=="NJ")

FusionPro.Composition.composeThisRecord = true;

 

 

Upon composing I receive error 1036

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...