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
hkp716hkp716 

Trigger give me an error

Hi Everyone,

 

I want to uncheck a checkbox after I save a record.  I have a vadation rule stating the checkbox should be checked if status is "new".  Even if the status is "new" i want the trigger to uncheck the box after save so if someone edits the record they have to recheck the box, if the status is still new.

 

My Trigger:

trigger Uncheckbox on Lead (after update) {

for (Lead cb : Trigger.new) {
if (cb.Confirm_New_Status__c == true) {

Lead ourcb = new Lead (Confirm_New_Status__c=false);


update ourcb;

}
}
}

 

Any suggestions?

 

-Hkp716

 

Best Answer chosen by Admin (Salesforce Developers) 
hkp716hkp716

Hi John,

 

I tried using both but neither of them would work.  I decided to use workflows instead.  Thank for the input though.

 

-hkp716

All Answers

SFFSFF

This should be a before trigger:

 

trigger Uncheckbox on Lead (after update)
{
  for (Lead cb : Trigger.new)
  {
    if (cb.Confirm_New_Status__c == true)
    {
      cb.Confirm_New_Status__c=false;
    }
  }
}

Hope this helps,

hkp716hkp716

Hi John,

 

I tried using both but neither of them would work.  I decided to use workflows instead.  Thank for the input though.

 

-hkp716

This was selected as the best answer
linghongyong12@163.comlinghongyong12@163.com

trigger Uncheckbox on Lead (before update) {

for (Lead cb : Trigger.new) {
     if (cb.Confirm_New_Status__c == true)

     {
          cb.Confirm_New_Status__c=false;
      }

}

}