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
apsulliapsulli 

Validation on Junction Object - No syntax errors, but doesn't work

Hi - the issue I am having is that when using validation on a junction object, it looks like everything should be right, but just doesn't work at all.

 

For the purposes of this, the primary objects I'm working with are a custom promotional event object and the standard account object.

 

The logic is that I want to check if:

 

1. On the promotional event, the Event State (custom picklist field) is "NY"

2. On the account, the account state is one of a list of values

 

If the criteria is met, an error should be returned

 

If anyone can help or suggest a better way, I'm all ears!

 

Here's my validation formula:

 

AND(ISPICKVAL(Promotional_Event__r.Event_State__c,"NY"),Account__r.BillingState = "AK", Account__r.BillingState = "AZ",Account__r.BillingState = "AR",Account__r.BillingState = "CA",Account__r.BillingState = "CO",Account__r.BillingState = "HI",Account__r.BillingState = "ID",Account__r.BillingState = "IA",Account__r.BillingState = "KS",Account__r.BillingState = "LA",Account__r.BillingState = "MN",Account__r.BillingState = "MO",Account__r.BillingState = "MT",Account__r.BillingState = "NE",Account__r.BillingState = "NV",Account__r.BillingState = "NM",Account__r.BillingState = "ND",Account__r.BillingState = "OK",Account__r.BillingState = "OR",Account__r.BillingState = "SD",Account__r.BillingState = "TX",Account__r.BillingState = "UT",Account__r.BillingState = "WA",Account__r.BillingState = "WY")

Best Answer chosen by Admin (Salesforce Developers) 
Jeff MayJeff May

The structure of your formula should be AND(NY, OR()).  Shorthand syntax is:  AND(ISPICKVAL(Event, 'NY), OR(BillingState = 'AK", BillingState = 'AZ') )

All Answers

Jeff MayJeff May

The structure of your formula should be AND(NY, OR()).  Shorthand syntax is:  AND(ISPICKVAL(Event, 'NY), OR(BillingState = 'AK", BillingState = 'AZ') )

This was selected as the best answer
apsulliapsulli

Oh great!  This is perfect, thanks.  Works!