MarcomCentral (PTI) and FusionPro User Communities

MarcomCentral (PTI) and FusionPro User Communities (http://forums.pti.com/index.php)
-   FusionPro® Expression™ (http://forums.pti.com/forumdisplay.php?f=51)
-   -   OnRecordStart Execution (http://forums.pti.com/showthread.php?t=5360)

AWhite2504 June 3rd, 2019 07:53 AM

OnRecordStart Execution
 
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;

ScottHillock June 3rd, 2019 09:07 AM

Re: OnRecordStart Execution
 
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.

Code:

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;
}


AWhite2504 June 3rd, 2019 10:00 AM

Re: OnRecordStart Execution
 
This worked! Thank you soooo much!!

Dan Korn June 3rd, 2019 10:01 AM

Re: OnRecordStart Execution
 
Code:

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 -
Code:

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) != "";
}


AWhite2504 August 12th, 2019 12:25 PM

Re: OnRecordStart Execution
 
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


All times are GMT -7. The time now is 06:01 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.