Go Back   MarcomCentral (PTI) and FusionPro User Communities > Support > Issues, Questions, Etc.

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 13th, 2012, 07:45 AM
dleahy's Avatar
dleahy dleahy is offline
%%UserTitle%%
 
Join Date: Nov 2011
Location: Lowell, MA
Posts: 51
Exclamation with Onrecordstart rule

Have three pages in my PDF (Body 1, Body 2, Body 3)

Trying to get them to displayed based on values entered in a field called "SelectStyle"

Basically what I want to accomplish is this:
IF Field SelectStyle = "FJ Icon (M)" then display Body 2
IF Field SelectStyle = "DryJoys Tour (M)" then display Body 3
ELSE display Body 1


Here is what I got that's not working:
Code:
if (GetFileName(Field("SelectStyle")) == "FJ Icon (M)")
{
FusionPro.Composition.SetBodyPageUsage("Body2", true);
FusionPro.Composition.SetBodyPageUsage("Body1", false);
FusionPro.Composition.SetBodyPageUsage("Body3", false)
{
if (GetFileName(Field("SelectStyle")) == "DryJoys Tour (M)") 
{
FusionPro.Composition.SetBodyPageUsage("Body3", true);
FusionPro.Composition.SetBodyPageUsage("Body2", false);
FusionPro.Composition.SetBodyPageUsage("Body1", false)
}
else 
FusionPro.Composition.SetBodyPageUsage("Body1", true);
FusionPro.Composition.SetBodyPageUsage("Body2",false);
FusionPro.Composition.SetBodyPageUsage("Body3",false)
}}
Can anyone see what I'm doing wrong?!?

Thanks ahead of time!
__________________
Dan Leahy
Web Development & Prepress Specialist
DS Graphics Inc.
FusionPro VDP Designer 8.2.7
MarcomCentral & Exact Target
Reply With Quote
  #2  
Old June 13th, 2012, 07:56 AM
esmith's Avatar
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 870
Default Re: with Onrecordstart rule

Quote:
Originally Posted by dleahy View Post
anyone see what I'm doing wrong?!?
I edited your code with a few minor adjustments. My changes are in red:
Code:
if (Field("SelectStyle") == "FJ Icon (M)")
{
FusionPro.Composition.SetBodyPageUsage("Body2", true);
FusionPro.Composition.SetBodyPageUsage("Body1", false);
FusionPro.Composition.SetBodyPageUsage("Body3", false)
}
else if (Field("SelectStyle") == "DryJoys Tour (M)") 
{
FusionPro.Composition.SetBodyPageUsage("Body3", true);
FusionPro.Composition.SetBodyPageUsage("Body2", false);
FusionPro.Composition.SetBodyPageUsage("Body1", false)
}
else
{
FusionPro.Composition.SetBodyPageUsage("Body1", true);
FusionPro.Composition.SetBodyPageUsage("Body2",false);
FusionPro.Composition.SetBodyPageUsage("Body3",false)
}
I also removed the GetFileName() code and some unnecessary brackets. There are other ways to set this logic up that simplify the rule, but your logic is not incorrect.
__________________
Eric Smith
Content Developer
Classic
FP 9.3.6, MAC OSX 10.9.4, Acrobat 11.0.09
Reply With Quote
  #3  
Old June 13th, 2012, 08:54 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,305
Default Re: with Onrecordstart rule

Set all three body pages to Unused in the Page Usage dialog, then the rule can simply do this:
Code:
switch (Field("SelectStyle"))
{
  case "FJ Icon (M)":
    FusionPro.Composition.SetBodyPageUsage("Body2", true);
    break;
  case "DryJoys Tour (M)":
    FusionPro.Composition.SetBodyPageUsage("Body3", true);
    break;
  default:
    FusionPro.Composition.SetBodyPageUsage("Body1", true);
}
__________________
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
  #4  
Old June 13th, 2012, 09:00 AM
dleahy's Avatar
dleahy dleahy is offline
%%UserTitle%%
 
Join Date: Nov 2011
Location: Lowell, MA
Posts: 51
Default Re: with Onrecordstart rule

Big thanks to both of you on responding so quickly!

I actually found an example of the switch rule and applied it similar to what Dan just laid out...

__________________
Dan Leahy
Web Development & Prepress Specialist
DS Graphics Inc.
FusionPro VDP Designer 8.2.7
MarcomCentral & Exact Target
Reply With Quote
  #5  
Old June 14th, 2012, 05:47 AM
dleahy's Avatar
dleahy dleahy is offline
%%UserTitle%%
 
Join Date: Nov 2011
Location: Lowell, MA
Posts: 51
Default Re: with Onrecordstart rule

All,

I'm using the switch rule, like Dan mentioned above, on a new template I'm constructing. I need to be able to nest a else if statement in the switch rule yet I don't know quite how to do it. I have to take the code above:

Code:
switch (Field("SelectStyle"))
{
  case "FJ Icon (M)":
    FusionPro.Composition.SetBodyPageUsage("Body2", true);
    break;
  case "DryJoys Tour (M)":
    FusionPro.Composition.SetBodyPageUsage("Body3", true);
    break;
  default:
    FusionPro.Composition.SetBodyPageUsage("Body1", true);
}
and be able to say something like this logic:
Code:
switch (Field("SelectStyle"))
{
  case "FJ Icon (M)":
    FusionPro.Composition.SetBodyPageUsage("Body2", true);
else if Field("MemberGuestNameofEvent") == "" return
FusionPro.Composition.SetBodyPageUsage("Body4", true);
    break;
  case "DryJoys Tour (M)":
    FusionPro.Composition.SetBodyPageUsage("Body3", true);
    break;
  default:
    FusionPro.Composition.SetBodyPageUsage("Body1", true);
}
So basically I need to be able to say if SelectStyle = "FJ Icon (M)" then return "Body2" unless MemberGuestNameofEvent = "" then return "Body4"

Any help with that would be most appreciated!

-Dan
__________________
Dan Leahy
Web Development & Prepress Specialist
DS Graphics Inc.
FusionPro VDP Designer 8.2.7
MarcomCentral & Exact Target

Last edited by dleahy; June 14th, 2012 at 06:04 AM..
Reply With Quote
  #6  
Old June 14th, 2012, 08:49 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,305
Default Re: with Onrecordstart rule

Quote:
Originally Posted by dleahy View Post
So basically I need to be able to say if SelectStyle = "FJ Icon (M)" then return "Body2" unless MemberGuestNameofEvent = "" then return "Body4"
It's just a matter of getting the nesting right. This should work:
Code:
switch (Field("SelectStyle"))
{
  case "FJ Icon (M)":
    if (Field("MemberGuestNameofEvent") == "")
      FusionPro.Composition.SetBodyPageUsage("Body4", true);
    else
      FusionPro.Composition.SetBodyPageUsage("Body2", true);
    break;
  case "DryJoys Tour (M)":
    FusionPro.Composition.SetBodyPageUsage("Body3", true);
    break;
  default:
    FusionPro.Composition.SetBodyPageUsage("Body1", true);
}
This is equivalent, but a bit more succinct:
Code:
switch (Field("SelectStyle"))
{
  case "FJ Icon (M)":
    FusionPro.Composition.SetBodyPageUsage(Field("MemberGuestNameofEvent") ? "Body2" : "Body4", true);
    break;
  case "DryJoys Tour (M)":
    FusionPro.Composition.SetBodyPageUsage("Body3", true);
    break;
  default:
    FusionPro.Composition.SetBodyPageUsage("Body1", true);
}
And this would be pretty much the ultimate reduction of the logic:
Code:
function PageToActivate()
{
  switch (Field("SelectStyle"))
  {
    case "FJ Icon (M)":
      return Field("MemberGuestNameofEvent") ? "Body2" : "Body4";
    case "DryJoys Tour (M)":
      return "Body3";
    default:
      return "Body1";
  }
}

FusionPro.Composition.SetBodyPageUsage(PageToActivate(), true);
I like to abstract things out as much as possible and avoid repeating similar bits of code, but that's my geeky perfectionist programmer coming out.
__________________
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
  #7  
Old June 14th, 2012, 08:51 AM
dleahy's Avatar
dleahy dleahy is offline
%%UserTitle%%
 
Join Date: Nov 2011
Location: Lowell, MA
Posts: 51
Default Re: with Onrecordstart rule

I've never met a programmer who used the word succinct before.
You must of minored in English...
__________________
Dan Leahy
Web Development & Prepress Specialist
DS Graphics Inc.
FusionPro VDP Designer 8.2.7
MarcomCentral & Exact Target
Reply With Quote
  #8  
Old July 24th, 2012, 01:43 PM
dleahy's Avatar
dleahy dleahy is offline
%%UserTitle%%
 
Join Date: Nov 2011
Location: Lowell, MA
Posts: 51
Default Re: with Onrecordstart rule

Dan,

What if you have multiple fields to verify. This logic doesn't seem to work:

Code:
if (Field("SelectTopicCATone") != "")
{
FusionPro.Composition.SetBodyPageUsage("Body1", true);
}
else if (Field("SelectTopicCATtwo") != "")
{
FusionPro.Composition.SetBodyPageUsage("Body2", true) && FusionPro.Composition.SetBodyPageUsage("Body1", false);
}
else if (Field("SelectTopicCATthree") != "")
{
FusionPro.Composition.SetBodyPageUsage("Body3", true) && FusionPro.Composition.SetBodyPageUsage("Body2", false) && FusionPro.Composition.SetBodyPageUsage("Body1", false);
}
__________________
Dan Leahy
Web Development & Prepress Specialist
DS Graphics Inc.
FusionPro VDP Designer 8.2.7
MarcomCentral & Exact Target
Reply With Quote
  #9  
Old July 25th, 2012, 08:47 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,305
Default Re: with Onrecordstart rule

Quote:
Originally Posted by dleahy View Post
What if you have multiple fields to verify. This logic doesn't seem to work:
Code:
if (Field("SelectTopicCATone") != "")
{
FusionPro.Composition.SetBodyPageUsage("Body1", true);
}
else if (Field("SelectTopicCATtwo") != "")
{
FusionPro.Composition.SetBodyPageUsage("Body2", true) && FusionPro.Composition.SetBodyPageUsage("Body1", false);
}
else if (Field("SelectTopicCATthree") != "")
{
FusionPro.Composition.SetBodyPageUsage("Body3", true) && FusionPro.Composition.SetBodyPageUsage("Body2", false) && FusionPro.Composition.SetBodyPageUsage("Body1", false);
}
Don't use a logical AND operator (&&) in between two statements. This should work:
Code:
if (Field("SelectTopicCATone") != "")
{
  FusionPro.Composition.SetBodyPageUsage("Body1", true);
}
else if (Field("SelectTopicCATtwo") != "")
{
  FusionPro.Composition.SetBodyPageUsage("Body2", true);
  FusionPro.Composition.SetBodyPageUsage("Body1", false);
}
else if (Field("SelectTopicCATthree") != "")
{
  FusionPro.Composition.SetBodyPageUsage("Body3", true);
  FusionPro.Composition.SetBodyPageUsage("Body2", false);
  FusionPro.Composition.SetBodyPageUsage("Body1", false);
}
Again, though, if you set all three pages to be Unused initially, the rule becomes much simpler:
Code:
if (Field("SelectTopicCATone") != "")
  FusionPro.Composition.SetBodyPageUsage("Body1", true);
else if (Field("SelectTopicCATtwo") != "")
  FusionPro.Composition.SetBodyPageUsage("Body2", true);
else if (Field("SelectTopicCATthree") != "")
  FusionPro.Composition.SetBodyPageUsage("Body3", true);
Or, even better:
Code:
FusionPro.Composition.SetBodyPageUsage("Body1", Field("SelectTopicCATone") != "");
FusionPro.Composition.SetBodyPageUsage("Body2", Field("SelectTopicCATtwo") != "");
FusionPro.Composition.SetBodyPageUsage("Body3", Field("SelectTopicCATthree") != "");
__________________
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
  #10  
Old July 25th, 2012, 11:50 AM
dleahy's Avatar
dleahy dleahy is offline
%%UserTitle%%
 
Join Date: Nov 2011
Location: Lowell, MA
Posts: 51
Default Re: with Onrecordstart rule

This isn't working. Keeps giving me only the first page. I wonder if it is the "else ifs"...
__________________
Dan Leahy
Web Development & Prepress Specialist
DS Graphics Inc.
FusionPro VDP Designer 8.2.7
MarcomCentral & Exact Target
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 01:56 PM.


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