Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 10th, 2018, 11:21 AM
merski007 merski007 is offline
Junior Community Member
 
Join Date: Jan 2014
Location: Milwaukee, WI
Posts: 27
Default Reference an Object in a Function

Hello,

I'm having an issue with the Preview not displaying correctly. The rule I'm using validates correctly, but breaks on preview.

In a nutshell, here is the code for this function

// declare variable color hits
HIT_COLOR_BLACK = "black";
HIT_COLOR_WHITE = "white";

// create array of objects
HIT_COLOR_CHOICE = {1: HIT_COLOR_BLACK, 2: HIT_COLOR_WHITE};

// retrieve items in desired color
function getItem(item, colorNumber){
return '<color name=' + HIT_COLOR_CHOICE[colorNumber] + '>' + '<tracking newsize="6">' + item;
}


During positioning and proofing, we will switch the color hits globally, just to check our work.

When I validate the rule with this function, the correct results appear:
<color name=black><tracking newsize="6">pizza

but the color does not come through on preview. The text will default to the color set in the text box. I have the 'Treat returned string as tagged text' box checked, so it's not that.

If i hardcode the color value into the function, or use the variable name itself, the rule works. This would just cause a lot of work on my end to create a function for each color i have.

All help is appreciated.

Here are system details:
FP: 9.3.36
OS: Mac OS 10.12.6
Acrobat 11

Cheers,
Mark
Reply With Quote
  #2  
Old January 10th, 2018, 12:16 PM
merski007 merski007 is offline
Junior Community Member
 
Join Date: Jan 2014
Location: Milwaukee, WI
Posts: 27
Default Re: Reference an Object in a Function

I figured out what I was doing wrong. All my functions were declared in OnJobStart via remotes js files. I had to declare the HIT_COLOR_CHOICE object array in OnRecordStart.

Once i did that, everything works.
Reply With Quote
Reply

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


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