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
shobana Ganesanshobana Ganesan 

After selecting a field my checkbox field should be checked on certain condition

Hi,

I need to check a checkbox field once the picklist value is selected,
Here are the details,
picklist field - pick__c('abc','pqr')
checkbox field - check1__c,check__c


If pick__c is 'abc' automatically check1__c should be checked and check2__c should be left unchecked and vice versa.

 
Best Answer chosen by shobana Ganesan
v varaprasadv varaprasad
Hi Shobana,

using 2 workflows we can achieve that or trigger. check sample code below.
 
trigger updatecheck on account(before insert,before update){

   for(account acc : trigger.new){
      if(acc.pick__c == 'abc'){
	     acc.check1__c = true;
		 acc.check2__c = false;
	  }else if(acc.pick__c == 'pqr'){
	     acc.check1__c = False;
		 acc.check2__c = True;
	  }
   
   }


}



Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.

Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
 

All Answers

v varaprasadv varaprasad
Hi Shobana,

using 2 workflows we can achieve that or trigger. check sample code below.
 
trigger updatecheck on account(before insert,before update){

   for(account acc : trigger.new){
      if(acc.pick__c == 'abc'){
	     acc.check1__c = true;
		 acc.check2__c = false;
	  }else if(acc.pick__c == 'pqr'){
	     acc.check1__c = False;
		 acc.check2__c = True;
	  }
   
   }


}



Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.

Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
 
This was selected as the best answer
Narender Singh(Nads)Narender Singh(Nads)

Hi Shobana,
You can create a workflow to do this task if you dont want to use the code. Also you can do it with the help of process builder. I would suggest doing it without code. But incase you need to do it via code then @Varaprasad's code should do the trick.
Thanks