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
javierjiesjavierjies 

Update with a Trigger

Hello everyone!!

 

I've an object called Expediente__c, where I have two fields; Cerrado__c (It's a Checkbox) and Situacion__c (It's a text field)

 

I want to develop a trigger to make automatically an update, I mean, if Cerrado__c changes to False, I want  Situacion__c='Cerrado'

 

 

any idea?!?!? thanks!!

Michael_KahleMichael_Kahle

Hi javierjies,

 

use a before trigger and just check if cerrado__c is false (and maybe wasn't before) and if so set the Situacion__c field.

 

 

for(Expediente__c data : trigger.new) { if(!data.cerrado__c) // need to check here too if you want to check old Value { data.Situacion__c = 'Cerrado'; } }

 

Because of the before trigger the change will be set without updating anything.