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

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 15th, 2013, 02:16 PM
kelly.anderson kelly.anderson is offline
Forum n00b
 
Join Date: Dec 2012
Posts: 7
Question OnRecord Start rule for page selection Error

I have a multi-page PDF that will use only one of the pages based on the state the user selects. I've set all of the pages to "Unused" under manage pages, and have created a rule for OnRecordStart. This rule works fine and gives me the results I expect. However, it gives me the error "Function Does Not Return a Value" when I save the rule. It also gives me an error when I compose it, but the composed file IS correct. I'm guessing that my script is missing something. Here's what I have in OnRecordStart:

if (Field("State") == "Florida")
{
FusionPro.Composition.SetBodyPageUsage("MC34310_FL ", true);
}

else if (Field("State") == "New Hampshire")
{
FusionPro.Composition.SetBodyPageUsage("MC34285_NH ", true);
}

else if (Field("State") == "New York")
{
FusionPro.Composition.SetBodyPageUsage("MC34467_NY ", true);
}

else if (Field("State") == "Texas")
{
FusionPro.Composition.SetBodyPageUsage("MC34700_TX _1210", true);
}
else
{
FusionPro.Composition.SetBodyPageUsage("MC34188", true);
}
Reply With Quote
  #2  
Old March 15th, 2013, 02:24 PM
Alex Marshall's Avatar
Alex Marshall Alex Marshall is offline
FusionPro VDP Support
 
Join Date: Sep 2008
Location: Chicago,Illinois
Posts: 380
Default Re: OnRecord Start rule for page selection Error

Did you forget that you have to name each page in the FusionPro > Manage Pages > Page Usage menu so that they match the callouts in the logic?
Also, set the first page to "used" and the rest of the pages in the template to "Unused".
Reply With Quote
  #3  
Old March 15th, 2013, 03:16 PM
esmith's Avatar
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 870
Default Re: OnRecord Start rule for page selection Error

Quote:
Originally Posted by Alex Marshall View Post
Also, set the first page to "used" and the rest of the pages in the template to "Unused".
This is the 2nd time I have seen you post this advice. Can you explain your logic?

It is perfectly acceptable to have all pages in your template set as Unused in the Manage Pages dialog as long as your callback rule activates at least one page for every record.
__________________
Eric Smith
Content Developer
Classic
FP 9.3.6, MAC OSX 10.9.4, Acrobat 11.0.09
Reply With Quote
  #4  
Old March 15th, 2013, 03:50 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,297
Default Re: OnRecord Start rule for page selection Error

Quote:
Originally Posted by kelly.anderson View Post
I have a multi-page PDF that will use only one of the pages based on the state the user selects. I've set all of the pages to "Unused" under manage pages, and have created a rule for OnRecordStart. This rule works fine and gives me the results I expect. However, it gives me the error "Function Does Not Return a Value" when I save the rule. It also gives me an error when I compose it, but the composed file IS correct. I'm guessing that my script is missing something.
What do you mean you get an error when you save the rule? When you click Validate? Callback rules shouldn't require a return value. Are you sure that you created a callback rule? What is the Return Type shown in the Rules dialog?

Also, your logic seems fine, but I would collapse all of those "if/else if" statements into a "switch" statement, like so:
Code:
var pageName = "";
switch (Field("State"))
{
    case "Florida":
        pageName = "MC34310_FL";
        break;

    case "New Hampshire":
        pageName = "MC34285_NH";
        break;

// ...
// etc.
// ...

    default:
        pageName = "MC34188";
}

FusionPro.Composition.SetBodyPageUsage(pageName, true);
Or, even more succinctly:
Code:
var StateToPageNames =
{
    "Florida": "MC34310_FL",
    "New Hampshire": "MC34285_NH",
    // etc.
};

var pageName = StateToPageNames[Field("State")] || "MC34188";
FusionPro.Composition.SetBodyPageUsage(pageName, true);
Of course, the most succinct way to do it is to simply give the pages the same names as the states, and then the entire rule collapses down to this:
Code:
try
{
    FusionPro.Composition.SetBodyPageUsage(Field("State"), true);
}
catch (e)
{
    Print(e);
    FusionPro.Composition.SetBodyPageUsage("NoState", 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
  #5  
Old March 18th, 2013, 08:36 AM
kelly.anderson kelly.anderson is offline
Forum n00b
 
Join Date: Dec 2012
Posts: 7
Default Re: OnRecord Start rule for page selection Error

I have tried several iterations of the rule, including the simplified switch rule such as the one you suggested, but I still get the same error, "Function does not return a value."

I have double-checked the names of the pages and they do match what is in my rule.

It is a Callback rule – an OnRecord Start rule.

I have tried writing a rule to do the opposite, to initially have all my pages set to "Used" and then have the rule turn off all the unwanted pages. That rule does not give me an error message, but is a very long and cumbersome rule. It is almost like the program wants to have at least one page initially set to "Used" under Manage Pages. And as I said before, it WORKS, but it gives me an error message anyway. I hate to just ignore the message, but I'm not sure what is causing it.
Reply With Quote
  #6  
Old March 18th, 2013, 09:03 AM
kelly.anderson kelly.anderson is offline
Forum n00b
 
Join Date: Dec 2012
Posts: 7
Lightbulb Re: OnRecord Start rule for page selection Error

I've found out the error!
I was working on a file that a coworker had started, and discovered that she had named her rule OnRecordStart, but that it wasn't the callback rule. I've copied my rule over to the OnRecordStart Callback rule, and it now works without an error.

Thanks for the feedback!
Reply With Quote
Reply

Tags
javascript, multi, onrecordstart, page, pagecomposition

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 08:34 AM.


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