+ Start a Discussion
Patrick LaFontePatrick LaFonte 

Contains compare against multiple text values

can someone help me understand why this doesnt work for multiple values? 

<p>{!if(CONTAINS(relatedTo.Account.ShippingPostalCode,"17837:12221"),"EST","not found")}
</p>

If I compare for just one value i get expected result. 
EX:
<p>{!if(CONTAINS(relatedTo.Account.ShippingPostalCode,"17837"),"EST","not found")}
</p>

Working on a visualforce email template and need a way to compare a significant amount of zipcodes and return time zone.

Thanks
Dinesh GopalakrishnanDinesh Gopalakrishnan
Hi Patrick,

I tried to recreate the same in my dev Org but it's working as the way you expected.Can you compare the below merge expression with your version.

<messaging:emailTemplate subject="Test" recipientType="User" relatedToType="Account">
<messaging:plainTextEmailBody >
Congratulations!
This is your new Visualforce Email Template.
<p>{!if(CONTAINS(relatedTo.ShippingPostalCode,"17837:12221"),"EST","not found")}</p>
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

Kindly Mark this as a Best Answer if you Find this Useful!

Thanks
DineshKumar Gopalakrishnan
Patrick LaFontePatrick LaFonte
Hi DineshKumarm, To clarify I am able to save both versions. However if you actually test it against a zip code on a related account it only works for 1 compare value. EX:

{!if(CONTAINS(relatedTo.Account.ShippingPostalCode,"17837:12221"),"EST","not found")}

Account.ShippingPostalCode = 17837 Result = not found (should be EST) Vs

{!if(CONTAINS(relatedTo.Account.ShippingPostalCode,"17837"),"EST","not found")}

Account.ShippingPostalCode = 17837 Result = EST as expected Let me know if any insights as I have spent hours trying to figure this out. Thanks, Patrick Sensitivity: Internal