Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > FusionPro® Expression™

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 3rd, 2019, 07:53 AM
AWhite2504 AWhite2504 is offline
Junior Community Member
 
Join Date: May 2019
Posts: 17
Default 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;
Reply With Quote
  #2  
Old June 3rd, 2019, 09:07 AM
ScottHillock ScottHillock is offline
Regular Contributor
 
Join Date: Mar 2010
Posts: 91
Default 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;
}
__________________
FusionPro 9.3.36 - Acrobat 11 - macOS 10.14
Reply With Quote
  #3  
Old June 3rd, 2019, 10:00 AM
AWhite2504 AWhite2504 is offline
Junior Community Member
 
Join Date: May 2019
Posts: 17
Default Re: OnRecordStart Execution

This worked! Thank you soooo much!!
Reply With Quote
  #4  
Old June 3rd, 2019, 10:01 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,322
Default 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) != "";
}
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #5  
Old August 12th, 2019, 12:25 PM
AWhite2504 AWhite2504 is offline
Junior Community Member
 
Join Date: May 2019
Posts: 17
Default 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
__________________
Fusion Pro: 10.1.11
Acrobat :
Reply With Quote
Reply

Tags
onrecordstart

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:48 PM.


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