I want to run a trigger on a parent record when a child record is deleted. However I don't seem to be able to make this happen. I'm using Rollbase version 220.127.116.11.
Idea 1: In the child record add a "Run Trigger on Related Record" that will call the trigger on the parent record after the child record is deleted.
Oh No - The "After Delete" is disabled. Why is this?
Idea 2: Run an "Object Script" trigger on the child record After Delete
Oh No - The "After Delete" is disable again. No explanation as to why again.
Idea 3: Read documentation (doh!) - Hmmmm, nothing in there about the "After Delete" checkbox being disabled under certain circumstances. However I find this nugget on page 270.
When record is attached or detached using UI links in Related List component the system runs "After Update" triggers on both sides
Ah-Ha - I'll add an After Update to the parent record. When the child record is deleted the trigger will run.
I create a trigger on the parent object, set it to run "After Update" to create an activity log entry on "Any Update" to the object.
In the parent objects view page, I change a text field value on the parent record. I check the activity log. Yup an entry was added to the activity log as expected.
I delete a child record. I check the activity log. Oh No - Nothing added to the activity log. How could this be?
So I'm out of ideas here am I missing something obvious?
That works!!! Thank you so much, I really appreciate it.
Can I send you a box of chocolates?
Can you run triggers "before delete" instead?
No, The trigger I want to run on the parent needs to be run after the child has been removed.
I'm not sure I understand all reasoning correctly, but when record is deleted - its gone. So it may not be possible to do what you want.
If there is no way to run a trigger after an object is deleted, its seems odd that Rollbase would even have a "After Delete" checkbox that is there but disabled. The documentation say nothing about this.
What about my idea 3? Why wouldn't the parent's record fire "After Update" when a related document is deleted, as the documentations states that it should?
It appears there is no way for a parent record to be notified when one of its children are removed.
Tracking as PSC00314155
Does PSC00314155 mean that this is a bug?
This is enhancement request:
Need to allow running "Run Triggers on Related Records" triggers after record's delete to notify related records
I will look into this issue more closely.
Ok thanks. The documentation states: "When record is attached or detached using UI links in Related List component the system runs "After Update" triggers on both sides"
So either I'm not configuring something correctly or its a regression bug of some kind.
Is there any proposed workaround?
I'm investigating, but I don't have any workaround at this time.
We also had this need in the past, to be able to run triggers on related records after a record is deleted.
As awbranch is stating, this is not possible using the "Run Trigger on Related Record" or the "Object script" types of triggers.
However, there is a workaround using the "Update Field Value" type of trigger. This trigger can be processed after delete.
You just have to chose an arbitrary field to update (it doesn't matter which one because the record is gonna get deleted anyway), and you can write "rbv_api.runTrigger" statements to call a trigger of the parent's record.
We have been using this workaround for more than a year, and it is working fine for us, even though we would prefer being able to use "Run Trigger on Related Record" or the "Object script" types of triggers.
I would love that, but I'm in France, so this may be quite hard to achieve!
No problem. Send me your address and I'll make it happen.