PDA

View Full Version : Switch Rule and Ampersand


bmauer
February 11th, 2011, 01:23 PM
I created a switch rule so that the text field "Division" will change depending on what text is in text field "Function".

switch (Field("Function"))
{
case "A & B PRODUCTS":
return "DIVISION OF A & B COMPANIES, INC.";
case "A B PRODUCTS":
return "DIVISION OF A & B COMPANIES, INC.";
default:
return "";
}

The code works fine as long as in the case, there is no ampersand.

if the case is A & B PRODUCTS, it will not return the string DIVISION OF A & B COMPANIES, INC.
if the case is A B PRODUCTS, it returns the string DIVISION OF A & B COMPANIES, INC.

How do I correct this ampersand issue?

Rule code below:

switch (Field("Function"))
{
case "A & B PRODUCTS":
return "DIVISION OF A & B COMPANIES, INC.";
default:
return "";
}

jstehman
February 11th, 2011, 02:09 PM
The easiest way to fix this is is to change the dropdown & the case. It will not affect the return:

switch (Field("Function"))
{
case "CONSUMER AND PERSONAL PRODUCTS WORLDWIDE":
return "DIVISION OF JOHNSON & JOHNSON CONSUMER COMPANIES, INC.";
default:
return "";
}

Jeff Stehman
Technical Support | PTI Marketing Technologies | Printable Technologies, Inc.
jstehman@pti.com | www.pti.com
858.847.6622 direct | 800.220.1727 office

bmauer
February 11th, 2011, 02:15 PM
It will also work if in the rule I change the case & to &

Thanks Jeff