#1
|
|||
|
|||
![]()
Hello All -
I've run into a problem, where my Javascript rule works perfectly within Fusion Pro, but not within Marcom. The rule: var redSubOne = "<color name = \"PANTONE Red 032 C\">" + Field("dynamicSubOne") + "</color>"; var blueSubOne = "<color name = \"PANTONE 2945 C\">" + Field("dynamicSubOne") + "</color>"; var graySubOne = "<color name = \"PANTONE 430 C\">" + Field("dynamicSubOne") + "</color>"; var purpleSubOne = "<color name = \"PANTONE 266 C\">" + Field("dynamicSubOne") + "</color>"; if(Field("headerImage") == ("red.pdf")){ return redSubOne.toUpperCase(); }else if(Field("headerImage")== ("blue.pdf")){ return blueSubOne.toUpperCase(); }else if(Field("headerImage")==("gray.pdf")){ return graySubOne.toUpperCase(); }else{ return purpleSubOne.toUpperCase(); } The Problem: Within Marcom, the rule defaults to the final "else" statement, always returning the purple font. Again, this rules work fine within Fusion Pro. Any thoughts or input would be very much appreciated. Thanks! |
#2
|
||||
|
||||
![]()
Personally, I've never used MarcomCentral (there's a completely separate forum for MC specific questions that you may have better luck with) but if it's always defaulting to the purple color, I would think that MC is reading the value of the "headerImage" field differently than FP is locally. My suspicion is that in MC perhaps the field value is prepended with a path to the pdf? If that's the case, one way to get around that would be to use the "GetFileName" function to basically remove the path from the field value when checking if it's equal to "red.pdf" or whatever value:
Code:
if(GetFileName(Field("headerImage")) == ("red.pdf")){ return redSubOne.toUpperCase(); } . . . Code:
var redSubOne = "<color name = \"PANTONE Red 032 C\">" + ToUpper(Field("dynamicSubOne")) + "</color>"; Code:
var color = ''; switch (GetFileName(Field("headerImage"))){ case "red.pdf": color = "PANTONE Red 032 C"; break; case "blue.pdf": color = "PANTONE 2945 C"; break; case "gray.pdf": color = "PANTONE 430 C"; break; default: color = "PANTONE 266 C"; } return '<color name="' + color + '">' + ToUpper(Field("dynamicSubOne")) + '</color>'; Code:
var header = String(Field("headerImage").match(/(red|blue|gray)\.pdf/ig)); var color = ''; switch (ToLower(header)){ case "red.pdf": color = "PANTONE Red 032 C"; break; case "blue.pdf": color = "PANTONE 2945 C"; break; case "gray.pdf": color = "PANTONE 430 C"; break; default: color = "PANTONE 266 C"; } return '<color name="' + color + '">' + ToUpper(Field("dynamicSubOne")) + '</color>';
__________________
Ste Pennell FusionPro VDP Creator 9.3.15 Adobe Acrobat X 10.1.1 Mac OS X 10.12 |
#3
|
|||
|
|||
![]()
Thanks Ste!
That worked perfectly, and a much more elegant solution. Much Appreciated! Matt |
![]() |
Tags |
font not working, javascript |
Thread Tools | Search this Thread |
Display Modes | |
|
|