Hi, I would like to create a before save hook, that will discard all the changes the user has made except for one field.
So somthing like this:
Load bean
$notes = $bean->notes
reset $bean to before changes were made
$bean->notes = $notes
$bean->save();
The issue trying to figure out how to reset the bean.
I know how to do this for indiviual fields. using
$bean->field = $bean->fetched_row['field ']
Is there a way of using this logic to restore the whole bean?
I have also tried reloading the bean with
BeanFactory::getBean('Cases', $bean->id);
but it loads the same bean (with the current edits). using this way, i would need a why to tell the bean not to save or to cancel cancel and then reload it.
Any help on eith of my suggestions or any new sufggestions would be great.
Thanks, but how do you update a single field before the redirect. If i run $bean->save() it will update all records, if i don’t, nothing will ve saved. How do i just update a single field to the bean?
The onyl way i can think of is using SQL, but this is not ideal, as it will not be capatured in the audit log.
You are right. As I mentioned on my previous post, you can use a query to update the value on the table. Then you can use another query to add the value to the audit table and redirect before save.