MarcomCentral (PTI) and FusionPro User Communities

MarcomCentral (PTI) and FusionPro User Communities (http://forums.pti.com/index.php)
-   FusionPro® VDP Creator (http://forums.pti.com/forumdisplay.php?f=5)
-   -   Help with conditional Rule (http://forums.pti.com/showthread.php?t=4707)

cmartin October 19th, 2016 09:36 AM

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

step October 19th, 2016 09:59 AM

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>';

cmartin October 19th, 2016 10:09 AM

Re: Help with conditional Rule
 
Quote:

Originally Posted by step (Post 19270)
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

cmartin October 19th, 2016 10:33 AM

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(" • ");

step October 19th, 2016 11:14 AM

Re: Help with conditional Rule
 
Quote:

Originally Posted by cmartin (Post 19272)
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");


cmartin October 19th, 2016 12:12 PM

Re: Help with conditional Rule
 
Quote:

Originally Posted by step (Post 19273)
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?

step October 19th, 2016 12:27 PM

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.

cmartin October 19th, 2016 01:28 PM

Re: Help with conditional Rule
 
Quote:

Originally Posted by step (Post 19275)
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.

step October 19th, 2016 02:14 PM

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> ' : '';

cmartin October 20th, 2016 07:20 AM

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.


All times are GMT -7. The time now is 04:47 AM.

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