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

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 19th, 2016, 10:36 AM
cmartin cmartin is offline
Junior Community Member
 
Join Date: Jun 2014
Posts: 15
Default Help with conditional Rule

I have seen similar things posted but could not get those changed to work for what I need.

Trying to create a conditional rule to where bullets are added if there is more than one field or rule on the line. Also, the bullets need to be in a color (Pantone 801) defined in the document.

t. 888.999.6666 • f. 888.999.6666 • d. 888.999.6666
t. 888.999.6666 • f. 888.999.6666
t. 888.999.6666
f. 888.999.6666 • d. 888.999.6666
Reply With Quote
  #2  
Old October 19th, 2016, 10:59 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Help with conditional Rule

Take a look at this thread: http://forums.pti.com/showthread.php?t=3554

It discusses your scenario almost exactly. The only difference would be the color bullet points. Assuming you've defined "PANTONE 801" in your FP template, you can apply color to a bullet like this:
Code:
return '<color name="PANTONE 801"> • </color>';
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #3  
Old October 19th, 2016, 11:09 AM
cmartin cmartin is offline
Junior Community Member
 
Join Date: Jun 2014
Posts: 15
Default Re: Help with conditional Rule

Quote:
Originally Posted by step View Post
Take a look at this thread: http://forums.pti.com/showthread.php?t=3554

It discusses your scenario almost exactly. The only difference would be the color bullet points. Assuming you've defined "PANTONE 801" in your FP template, you can apply color to a bullet like this:
Code:
return '<color name="PANTONE 801"> • </color>';
That was one of the threads I was trying follow to change to work.

Here is what I am trying and it is not adding the bullet.

var office = (Rule("tagPhone1")) + (Rule("Change phone format Rule"))
var fax = (Rule("tagPhone2")) + (Rule("Change fax phone format Rule"))

var numbers = [office + fax];

return numbers.filter(function(m){return m.match(/.*\s(?=.)/);}).join(" • ");

I get:
t. 901.484.4274 f. 281.989.6950
Reply With Quote
  #4  
Old October 19th, 2016, 11:33 AM
cmartin cmartin is offline
Junior Community Member
 
Join Date: Jun 2014
Posts: 15
Default Re: Help with conditional Rule

Got it fix to show the bullet now. How do I add the color change to it?

var office = (Rule("tagPhone1")) + (Rule("Change phone format Rule"))
var fax = (Rule("tagPhone2")) + (Rule("Change fax phone format Rule"))

var numbers = [office,fax];

return numbers.filter(function(m){return m.match(/.*\s(?=.)/);}).join(" • ");
Reply With Quote
  #5  
Old October 19th, 2016, 12:14 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Help with conditional Rule

Quote:
Originally Posted by cmartin View Post
Got it fix to show the bullet now. How do I add the color change to it?
Replace the bullet in the join method with the tag I posted in my first reply:
Code:
var office = (Rule("tagPhone1")) + (Rule("Change phone format Rule"))
var fax = (Rule("tagPhone2")) + (Rule("Change fax phone format Rule"))

var numbers = [office,fax];

return numbers.filter(function(m){return m.match(/.*\s(?=.)/);}).join('<color name="PANTONE 801"> • </color>');
Also, there's nothing wrong with putting parentheses around your "Rule" functions, but you don't need them. So, you could save yourself a few keystrokes and define your variables as:
Code:
var office = Rule("tagPhone1") + Rule("Change phone format Rule");
var fax = Rule("tagPhone2") + Rule("Change fax phone format Rule");
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #6  
Old October 19th, 2016, 01:12 PM
cmartin cmartin is offline
Junior Community Member
 
Join Date: Jun 2014
Posts: 15
Default Re: Help with conditional Rule

Quote:
Originally Posted by step View Post
Replace the bullet in the join method with the tag I posted in my first reply:
Code:
var office = (Rule("tagPhone1")) + (Rule("Change phone format Rule"))
var fax = (Rule("tagPhone2")) + (Rule("Change fax phone format Rule"))

var numbers = [office,fax];

return numbers.filter(function(m){return m.match(/.*\s(?=.)/);}).join('<color name="PANTONE 801"> • </color>');
Also, there's nothing wrong with putting parentheses around your "Rule" functions, but you don't need them. So, you could save yourself a few keystrokes and define your variables as:
Code:
var office = Rule("tagPhone1") + Rule("Change phone format Rule");
var fax = Rule("tagPhone2") + Rule("Change fax phone format Rule");
Thanks for the help but the color line is not working.

Code:
var office = Rule("tagPhone1") + Rule("Change phone format Rule")
var fax = Rule("tagPhone2") + Rule("Change fax phone format Rule")

var numbers = [office,fax];

return numbers.filter(function(m){return m.match(/.*\s(?=.)/);}).join('<color name="PANTONE 801"> • </color>');
I get:
t. 901.484.4274 <color name="PANTONE 801"> • </color>f. 281.989.6950

I have tried different colors (Cyan, Yellow, etc). I have the color defined in Advanced<colors. Does it need to be defined somewhere else?
Reply With Quote
  #7  
Old October 19th, 2016, 01:27 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Help with conditional Rule

Since you're adding color tags to the bullet, you need to check the box beside "Treat returned strings as tagged text" at the top of your rule.
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #8  
Old October 19th, 2016, 02:28 PM
cmartin cmartin is offline
Junior Community Member
 
Join Date: Jun 2014
Posts: 15
Default Re: Help with conditional Rule

Quote:
Originally Posted by step View Post
Since you're adding color tags to the bullet, you need to check the box beside "Treat returned strings as tagged text" at the top of your rule.
Great! That did it.

Well, one last question.

Code:
if (Field("Phone") != "")
    return "t. ";
else
    return "";
How do I change the "t." to a different font? Sorry for the basic questions. I have exampels but they usually include point size to.
Reply With Quote
  #9  
Old October 19th, 2016, 03:14 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Help with conditional Rule

Similar to the "color" tag, there is also a "font" tag. You can find an example of how it works and a better explanation than I could give you on page 47 of the TagsRefGuide PDF that comes with FusionPro.

FusionPro > Documentation > Tags Reference

Code:
return Field("Phone") ? '<f name="Different Font">t.</f> ' : '';
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #10  
Old October 20th, 2016, 08:20 AM
cmartin cmartin is offline
Junior Community Member
 
Join Date: Jun 2014
Posts: 15
Default Re: Help with conditional Rule

Thanks for all the help. JavaScript is not my thing but trying to learn. That worked and of course one additional question.

I used that on 3 additional sections and it worked on 2 but not the other.

Here is the one that failed.

Code:
var email = Field("Email");
var web = Field("Website");

var numbers = [email,web];

return numbers.filter(function(m){return m.match(/.*\s(?=.)/);}).join('<color name="Pantone 801"> • </color>');
It just returns "return value" when validating it.
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 01:45 AM.


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