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

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 24th, 2017, 01:57 PM
jefff jefff is offline
Forum n00b
 
Join Date: Aug 2013
Location: St. Louis, MO
Posts: 6
Default Javascript Works for One Template but not the Other

I have a business card that has a minor alteration to it, I basically copied the template along with the accompanying scripts to create the new one.

The only difference between the two templates is instead of having stacked phone/cell numbers they want them to be side-by-side and slide over when either number is missing in the data.

Here is the script:

if (Field("Phone") == "")
return 'c '+Rule("Cell Dot Rule");
if (Field("Cell") == "")
return 'p '+Rule("Phone Dot Rule");
else
return 'p '+Rule("Phone Dot Rule")+ ' '+'c '+Rule("Cell Dot Rule")


Worked for the first template (stacked) but when the data is missing on the phone or cell number all I get is a blank text box on the new template.

Is this a scripting issue or Fusion Pro issue?
Reply With Quote
  #2  
Old January 24th, 2017, 02:01 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,549
Default Re: Javascript Works for One Template but not the Other

Quote:
Originally Posted by jefff View Post
Is this a scripting issue or Fusion Pro issue?
It's hard to say without seeing the job files. Are you sure you're actually calling out the rule in a text frame in the new template? Are there any warning or error messages in the composition log (.msg) file?
__________________
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
  #3  
Old January 24th, 2017, 02:21 PM
jefff jefff is offline
Forum n00b
 
Join Date: Aug 2013
Location: St. Louis, MO
Posts: 6
Default Re: Javascript Works for One Template but not the Other

No warning or error messages and the script works fine when both phone and cell number are present in data. The blank text box occurs when there is only one phone number or one cell number. Then the text box on the preview is empty.

Like I said, it worked fine on the first template when I had the phone and cell number stacked like this:

p 217.346.5467
c 217.257.4222

It's when I took out the return and made the numbers side-by-side like this that the issue occurs:

p 217.346.5467 c 217.257.4222

If there is no phone the cell number should slide over flush left but instead....everything disappears and the text box is empty.
Reply With Quote
  #4  
Old January 24th, 2017, 03:01 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Javascript Works for One Template but not the Other

It's kind of impossible to say based on the information you've provided.

What is the code for "Cell Dot Rule" and "Phone Dot Rule"? Have you checked the text frame in which you placed the new rule to see if "suppress if containing empty variables" is checked in your new template?

In any event, this code should work for you:
Code:
return [
  'p ' + Rule("Phone Dot Rule"),
  'c ' + Rule("Cell Dot Rule")
].filter(function(s){ return RawTextFromTagged(s).length > 2 }).join(' ');
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #5  
Old January 25th, 2017, 07:42 AM
jefff jefff is offline
Forum n00b
 
Join Date: Aug 2013
Location: St. Louis, MO
Posts: 6
Default Re: Javascript Works for One Template but not the Other

It turns out the "suppress if containing empty variables" was checked.

So, now my challenge is the "p" and "c" need to be a customer specified green color and the phone/cell numbers need to be dark gray. What code do I need to add to get the two different colors from the script?
Reply With Quote
  #6  
Old January 25th, 2017, 08:01 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Javascript Works for One Template but not the Other

You still haven't provided any more information about what the rules are doing. How were you changing the color in the first, working template? Check out page 48 of the FusionPro TagsRefGuide.pdf (FusionPro > Documentation > Tags Reference) for information on how to use color tags or search the forum to yield results like this thread or this one.
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #7  
Old January 25th, 2017, 09:05 AM
jefff jefff is offline
Forum n00b
 
Join Date: Aug 2013
Location: St. Louis, MO
Posts: 6
Default Re: Javascript Works for One Template but not the Other

OK, followed your advice and applied the color tag to the script. See Below.

if (Field("Phone") == "")
return '<color rgb="00B189">c </color>'+Rule("Cell Dot Rule");
if (Field("Cell") == "")
return '<color rgb="00B189">p </color>'+Rule("Phone Dot Rule");
else
return '<color rgb="00B189">p </color>'+Rule("Phone Dot Rule")+ ' '+'<color rgb="00B189">c </color>'+Rule("Cell Dot Rule")

According to the Fusion Pro manual the color tag I placed should do exactly what I need but it's still not working.

The rules "Phone Dot Rule" and "Cell Dot Rule" are only formatting the number to ensure periods are used instead of hyphens on the phone/cell numbers.
Reply With Quote
  #8  
Old January 25th, 2017, 09:31 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Javascript Works for One Template but not the Other

What do you mean by "still not working?" Initially, you said the code worked in one of your templates. What is the output you're seeing? Are you getting errors when composing? Can you collect and upload your template/data so that it would be to diagnose the issue?
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #9  
Old January 25th, 2017, 09:34 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,549
Default Re: Javascript Works for One Template but not the Other

Quote:
Originally Posted by jefff View Post
it's still not working.
Please be more specific. What is the intended result, and what is the actual result, and how are they different? A picture may be worth a thousand words, and a collected template that demonstrates the issue would be even better.
__________________
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 January 25th, 2017, 10:00 AM
jefff jefff is offline
Forum n00b
 
Join Date: Aug 2013
Location: St. Louis, MO
Posts: 6
Default Re: Javascript Works for One Template but not the Other

Collected Template attached.

I really don't know how to be any more clear on what I'm trying to achieve.

The script works like it should. It removes the phone number when none is present in the data, removes the cell when none is present in the data, and if both numbers are in the data they are there in the preview.

The only thing I can not get to work is the tag for the color. The "p" and "c" are green. The actual phone/cell numbers are 80% black.
Attached Files
File Type: zip PremiumRetail_v3.zip (4.05 MB, 10 views)
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 02:53 AM.


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