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
Cristian TrifCristian Trif 

Set a value for 2 dependent picklists

I need to update/change my Customer Type picklist field with the value of Detail Customer before I insert the Account. So the process is like this:
1) I press the new button for creating new account
2) Those 2 fields appear on the screen
3) When I select Customer Main Type picklist field with the value of Organization the Customer Type default value should be Detail Customer, and it should change instantly before I inserting my account. Remember, these two picklists are dependent and not controlling picklists.


I tried to write a trigger but I'm stuck here.. I'm not a programmer so I don't know how to continue this.

trigger ChangeValue on Account (before insert) {
    for (Account a :{
        if(a.CustomerMainType__c =='Organization'){
            a.CustomerType__c == 'Detail Customer';
I have 2 errors: Variable does not exist: CustomerMainType__c ; Variable does not exist: CustomerType__c.

And the fields should be like this when i select the Organization value.

User-added image

NagendraNagendra (Salesforce Developers) 
Hi Christian,

sorry for this issue you are facing.

May I suggest you please refer to below link from the success community with a similar discussion and a suggested workaround. Hope this helps.

Kindly close this thread by marking it as solved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.