Validation Rule - Can we use one for fields that we cant make mandatory? - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Gary ScottGary Scott 

Validation Rule - Can we use one for fields that we cant make mandatory?

Hi Community,

Can you help me with these queries?

We have a number of fields in our opportunities which cant be made mandatory across all accounts 

eg Accounts which are 'Universities' need the user to complete a field called 'Faculty' (as we need to report on this) but accounts which are 'Commercial' or 'Local Authority' do not require the 'Faculty' field to be compeleted.

We only need these fields completed at any of our 'Closed Won' stages and not at any other stages (Closed Won / Closed Won - Awatiing PO / Closed Won - Monthly)

If the user on a University account enters a particualr 'Faculty' (Tech) we would then require a field called 'Professor' to be completed.


How do I go about creating these? If there is a guide or an example somepbody could write, I can then build them for when required.


Thanks in advacne for any help
Best Answer chosen by Gary Scott
Amnon KruviAmnon Kruvi
Hi Gary, 

This is exactly what validation rules are for! 

In your case, you'll need a rule that looks like the following. Note that I'm making a few guesses here regarding how your data model works:
AND (
    Account.RecordType.DeveloperName = "University", 
    CONTAINS(TEXT(StageName), "Closed Won"), 
    ISBLANK(Faculty__c) 

 

All Answers

Amnon KruviAmnon Kruvi
Hi Gary, 

This is exactly what validation rules are for! 

In your case, you'll need a rule that looks like the following. Note that I'm making a few guesses here regarding how your data model works:
AND (
    Account.RecordType.DeveloperName = "University", 
    CONTAINS(TEXT(StageName), "Closed Won"), 
    ISBLANK(Faculty__c) 

 
This was selected as the best answer
Gary ScottGary Scott
Thanks Amnon,
In you ropinion would a flow be a better way to do this, so the users are only presented certain fields?
Amnon KruviAmnon Kruvi
That's normally not a recommended solution, but it really depends. Maybe quick actions for different account types? Maybe dynamic forms will work well for this in the next release. 

Still, validation rules should get you what you need right now. 
Gary ScottGary Scott
Thanks
Sorry I meant paths. i'll investigate