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
JaxBeachJaxBeach 

Formula is not working???

Hi,  this is the first portion of my formula that updates a sales region field based on states and distribution channel.  When I run it, it updates all of the commercial channel accounts with the first IF statement value of "Commercial Central/West"  I can't figure out why it isn't reading or looking at the other if statements.  I didn't get any limitation or syntax errors when I created it.

 

IF (ISPICKVAL(Channel__c , "Commercial") && NOT(CONTAINS ( ShippingState , "AK:AZ:CA:CO:HI:ID:MT:NV:NM:OR:UT:WA:WY")), "Commercial Central/West",
IF (ISPICKVAL(Channel__c , "Commercial") && NOT(CONTAINS ( ShippingState , "ND:SD:MN:WI:MO")), "Commercial North Central",
IF(ISPICKVAL(Channel__c, "Commercial") && NOT(CONTAINS(ShippingState, "TX,AR,LA,OK")), "Commercial TALO",
IF (ISPICKVAL(Channel__c , "Commercial") && NOT(CONTAINS ( ShippingState , "NE:KY:KS:MI:IA:IL:IN:OH")), "Commercial Midwest",
IF (ISPICKVAL(Channel__c , "Commercial") && NOT(CONTAINS ( ShippingState , "ME:CT:DE:FL:MD:MA:WV:NH:NJ:NY:PA:RI:VT:VA:DC")), "Commercial East",
IF (ISPICKVAL(Channel__c , "Commercial") && NOT(CONTAINS ( ShippingState , "NC:SC")), "Commercial NC/SC",
IF (ISPICKVAL(Channel__c , "Commercial") && NOT(CONTAINS ( ShippingState , "TN:GA:AL:MS")), "Commercial South East",
IF(ISPICKVAL(Channel__c, "Forensics") && NOT(CONTAINS(ShippingState,

Best Answer chosen by Admin (Salesforce Developers) 
@anilbathula@@anilbathula@

Hi JaxBeach,

Just try this formula ,i used contains instead of  NOT(Contains())
You can modified the out put value if the shipping state contains the Specified value.

IF (ISPICKVAL(Channel__c , "Commercial")&& CONTAINS ( "AK:AZ:CA:CO:HI:ID:MT:NV:NM:OR:UT:WA:WY",ShippingState),"Commercial Central/West ",
IF (ISPICKVAL(Channel__c , "Commercial")&& CONTAINS ( "ND:SD:MN:WI:MO",ShippingState ) , "Commercial North Central",
IF (ISPICKVAL(Channel__c , "Commercial")&& CONTAINS ( "TX:AR:LA:OK",ShippingState ) , "Commercial TALO",
IF (ISPICKVAL(Channel__c , "Commercial")&& CONTAINS ( "NE:KY:KS:MI:IA:IL:IN:OH",ShippingState), "Commercial Midwest",
IF (ISPICKVAL(Channel__c , "Commercial")&& CONTAINS ( "ME:CT:DE:FL:MD:MA:WV:NH:NJ:NY:PA:RI:VT:VA:DC",ShippingState ), "Commercial East",
IF (ISPICKVAL(Channel__c , "Commercial")&& CONTAINS ( "NC:SC",ShippingState ), "Commercial NC/SC",
IF (ISPICKVAL(Channel__c , "Commercial")&& CONTAINS ( "TN:GA:AL:MS", ShippingState ), "Commercial South East",NULL)))))))

All Answers

rbohnrbohn
Shouldn't your formula contain CONTAINS () instead of NOT (CONTAINS())
JaxBeachJaxBeach

I thought that too, but when I don't include the not, it just updates the field with a blank value.  The formula was written with help from developer community.  The rest of the formula contains regions for Domestic, Government and Forensics channels and they all update correctly.

@anilbathula@@anilbathula@

Hi JaxBeach,

Just try this formula ,i used contains instead of  NOT(Contains())
You can modified the out put value if the shipping state contains the Specified value.

IF (ISPICKVAL(Channel__c , "Commercial")&& CONTAINS ( "AK:AZ:CA:CO:HI:ID:MT:NV:NM:OR:UT:WA:WY",ShippingState),"Commercial Central/West ",
IF (ISPICKVAL(Channel__c , "Commercial")&& CONTAINS ( "ND:SD:MN:WI:MO",ShippingState ) , "Commercial North Central",
IF (ISPICKVAL(Channel__c , "Commercial")&& CONTAINS ( "TX:AR:LA:OK",ShippingState ) , "Commercial TALO",
IF (ISPICKVAL(Channel__c , "Commercial")&& CONTAINS ( "NE:KY:KS:MI:IA:IL:IN:OH",ShippingState), "Commercial Midwest",
IF (ISPICKVAL(Channel__c , "Commercial")&& CONTAINS ( "ME:CT:DE:FL:MD:MA:WV:NH:NJ:NY:PA:RI:VT:VA:DC",ShippingState ), "Commercial East",
IF (ISPICKVAL(Channel__c , "Commercial")&& CONTAINS ( "NC:SC",ShippingState ), "Commercial NC/SC",
IF (ISPICKVAL(Channel__c , "Commercial")&& CONTAINS ( "TN:GA:AL:MS", ShippingState ), "Commercial South East",NULL)))))))

This was selected as the best answer
JaxBeachJaxBeach

I had tried this before and it didn't work, but with your solution you moved shippingstate to after the states listed and now it is working - thanks so much!