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
Munira MajmundarMunira Majmundar 

Trigger and Order of Execution concept clarification missing :-(

One thing on this topic is not clear to me.

The developer document on the Trigger and Order to Execution states:
Before Salesforce executes these events on the server, the browser runs JavaScript validation if the record contains any dependent picklist fields. The validation limits each dependent picklist field to its available values. No other validation occurs on the client side.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm

I got it that the First action is performed on Client side - Browser runs Javascript validation and checks whether record contains any dependent picklist.  Fine.

BUT....

Why does the system check whether record contains any dependent picklist?
What does the system do if there is a dependent picklist?
What does the system do if there is NO dependent picklist?

In the same context, what does the following sentence even mean?
The validation limits each dependent picklist field to its available values.
huh????

Any help in clarifying the aforementioned conept will be highly appreciated.

Thanks,
Regards,
Munira
Best Answer chosen by Munira Majmundar
Prateek Singh SengarPrateek Singh Sengar
Hi Munira,
Yes in the above case, salesforce will automatically add a javascript to show cities based on state. This client side javascript will be executed first then followed by the normal execution criteria

All Answers

Prateek Singh SengarPrateek Singh Sengar
Hi Munira,
When you have a dependent picklist salesforce automatically adds an javascript, this statement means that before any other server side validation executes this javascript is executed, this javascript restricts the values on the dependent picklist. Now to answer your 3 questions

Why does the system check whether record contains any dependent picklist?
This is salesforce way of ensuring that only correct values are available for selection in case of dependent picklist. System with the help of this javascript ensures that only correct values are available for selection.

What does the system do if there is a dependent picklist?
Like mentioned in the statement it applies a javascript which restricts the value of dependent picklist, after this client side validation other execution criteria kicks in

What does the system do if there is NO dependent picklist?
Nothing, just the regular execution criteria kicks in as per the document.
Munira MajmundarMunira Majmundar
Hello Prateek:
Thanks for your prompt response.
So, basically, if State is a Controlling Picklist and City is a Dependent Picklist.  Salesforce runs Javascript validation to make sure that all expected cities are listed in the dependent picklist.  Right?

Regards,
Munira
Prateek Singh SengarPrateek Singh Sengar
Hi Munira,
Yes in the above case, salesforce will automatically add a javascript to show cities based on state. This client side javascript will be executed first then followed by the normal execution criteria
This was selected as the best answer
Munira MajmundarMunira Majmundar
Thanks... for all your help!
Munira MajmundarMunira Majmundar
Prateek:

While going is good, I am about to appear for my Platform App Builder Certification.  Any (last minute tip?)  I am currently trying to understand Trigger and Order of Execution :)