AWhite2504 Posted June 3, 2019 Share Posted June 3, 2019 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; Quote Link to comment Share on other sites More sharing options...
ScottHillock Posted June 3, 2019 Share Posted June 3, 2019 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; } Quote Link to comment Share on other sites More sharing options...
AWhite2504 Posted June 3, 2019 Author Share Posted June 3, 2019 This worked! Thank you soooo much!! Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted June 3, 2019 Share Posted June 3, 2019 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) != ""; } Quote Link to comment Share on other sites More sharing options...
AWhite2504 Posted August 12, 2019 Author Share Posted August 12, 2019 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.