Find your content:

Search form

You are here

Picklist formula help

 
Share

I'm trying to do validation for a values on a pick-list and a text field. I was thinking something like this.

IF(ISPICKVAL( SAP_Transportation_Zone__c , "USA") && (Country__c != "US")true,false)
OR(
SAP_Transportation_Zone__c,"CANADA" &&(Country__c != "CA")true,false)

This will continue to grow with all of my countries and their acceptable SAP_Transportation_Zone__c, this is my first time really attempting a formula and not sure really how to go about it. Something like this? Can someone point me in the right direction?


Attribution to: EricSSH

Possible Suggestion/Solution #1

If the SAP_Transportation_Zone__c field has ALWAYS the first 2 letters equal to the Country__c picklist, and also they're both required and should match, then you can do something like this I think:

IF(Country__c != LEFT(TEXT(SAP_Transportation_Zone__c), 2) , true, false)

So basically you get the first 2 letters from the transportation zone value and you make sure the country value matches. This way it's dynamic and will work for all values as long as the first 2 characters match.

For all the exclusions where the characters do not match, you can add an OR to the formula above.


Attribution to: Boris Bachovski

Possible Suggestion/Solution #2

Forgive me if this is no help, however IF there area limited number of Country Codes and relevant Transportation Zones, would it be useful to put them into a new object/table in SF (like a conversion table) and use a trigger to map them?

I'm still very much a newbie with apex so my apologies in advance if this is not the case!


Attribution to: Cerbera
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/31445

My Block Status

My Block Content