function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
msglsmomsglsmo 

Custom Forumula Field Help

Good Evening,

 

We use a custom formula field to update a field on our support cases with the account's warranty service provider.  We have one account that uses their own company to do warranty work, so I need that account to be updated differently.  Here is what I have:


IF(ISBLANK(ShippingState), "Unknown", IF (CONTAINS("Canada", ShippingCountry ), "ABC Co", IF(CONTAINS("FL", ShippingState), "DEF Co", IF(CONTAINS("CA:NJ", ShippingState), "GHI Co", IF(CONTAINS("AK:AZ:HA:NV:NM:OR:UT:WA:CO:ID:MT:KS:OK:TX:WY:NY:PA:AL:AR:DC:DE:KY:LA:MD:MS:TN:VA:WV:IL:IA:MI:MN:MO:NE:ND:SD:WI:ME:NH:VT:CT:MA:RI:OH:IN:NC:SC:GA", ShippingState), "JKL Co", IF (CONTAINS("XYYCompany", Name ), "N/A", "Unknown"))))))

 

The code works well, except that the XYYCompany account is still updated with the warranty service provider based on the State.

Any ideas on what I am doing wrong?

 

Thank you!

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
CaptainObviousCaptainObvious

Because company XYY is the exception, handle that case first by moving it up the chain:

IF(CONTAINS("XYYCompany", Name ), "N/A", IF(ISBLANK(ShippingState), "Unknown", IF(CONTAINS("Canada", ShippingCountry ), "ABC Co", IF(CONTAINS("FL", ShippingState), "DEF Co", IF(CONTAINS("CA:NJ", ShippingState), "GHI Co", IF(CONTAINS("AK:AZ:HA:NV:NM:OR:UT:WA:CO:ID: MT:KS:OK:TX:WY:NY:PA:AL:AR:DC:DE:KY:LA: MD:MS:TN:VA:WV:IL:IA:MI:MN:MO:NE:ND:SD: WI:ME:NH:VT:CT:MA:RI:OH:IN:NC:SC:GA", ShippingState), "JKL Co","Unknown"))))))

 

All Answers

CaptainObviousCaptainObvious

Because company XYY is the exception, handle that case first by moving it up the chain:

IF(CONTAINS("XYYCompany", Name ), "N/A", IF(ISBLANK(ShippingState), "Unknown", IF(CONTAINS("Canada", ShippingCountry ), "ABC Co", IF(CONTAINS("FL", ShippingState), "DEF Co", IF(CONTAINS("CA:NJ", ShippingState), "GHI Co", IF(CONTAINS("AK:AZ:HA:NV:NM:OR:UT:WA:CO:ID: MT:KS:OK:TX:WY:NY:PA:AL:AR:DC:DE:KY:LA: MD:MS:TN:VA:WV:IL:IA:MI:MN:MO:NE:ND:SD: WI:ME:NH:VT:CT:MA:RI:OH:IN:NC:SC:GA", ShippingState), "JKL Co","Unknown"))))))

 

This was selected as the best answer
msglsmomsglsmo

Thank you for the reply!  That worked perfectly.

 

I appreciate your help!