You need to sign in to do that
Don't have an account?
duke1
Process checkbox in Trigger
How can I process a checkbox field in apex code (not with DeveloperForce)? In my trigger I want to see if the field is checked and after processing it, uncheck the field. I cannot find examples of this. I want my user to check a checkbox of accounts to be processed, this will invoke the bulk trigger. Can anyone help? I can't find any examples after much searching.
I think your trigger needs to be BeforeUpdate. This will allow you to modify fields before the record is committed to the database. By having your trigger AfterUpdate, the record has already been committed and thus is read only.
All Answers
You just need to assign TRUE or FALSE value
for(account a : trigger.new)
a.checkbox = true;
Hi Srini,
I keep getting the following error when I update the checkbox to false at the end of my trigger:
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, SumCansTransTrigger: execution of AfterUpdate caused by: System.FinalException: Record is read-only
Do you know how to work around this problem?
Thanks,
Duke1
I think your trigger needs to be BeforeUpdate. This will allow you to modify fields before the record is committed to the database. By having your trigger AfterUpdate, the record has already been committed and thus is read only.
OK, thanks.