You need to sign in to do that
Don't have an account?
Linda 98
Change checkbox after trigger invoked.
Hi
I am having an after update trigger which fires when a checkbox is set to true. It then creates records in the related object.
After creating(after trigger functionality is implemented), I want to make the checkbox again as false programmatically. How can I achieve this?
I tried to make it false after building the list, but I am facing Read only error.
Thanks
I am having an after update trigger which fires when a checkbox is set to true. It then creates records in the related object.
After creating(after trigger functionality is implemented), I want to make the checkbox again as false programmatically. How can I achieve this?
I tried to make it false after building the list, but I am facing Read only error.
Thanks
In this condition you can use only 'before update' trigger because the field value of the object can be changed using trigger.new but only in case of before triggers. But in case of after triggers changing the values of the records in trigger.new context will throw an exception as "Record is read only".
Note:
1. Trigger.new and trigger.old are read only.
2. An object can change its own field values only in before trigger: trigger.new.
3. In all cases other than mentioned in point 2; fields values cannot be changed in trigger.new and would cause run time exception "record is read only".
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha.
This error occurs when you make DML operation in 'before Update'.Any changes made in a before-insert/before-update trigger will automatically be applied without a DML operation.
Try the following example it may be helpful for you: I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha