Detach a record - Trigger - New UI

Posted by IramK on 02-Nov-2015 08:49


When a record is attached/detached, we can use the after update event of a trigger to catch the event and perform our actions. Is there a way to detect what action is performed i.e. attach or detach from the trigger? Kindly let me know.



All Replies

Posted by Chandrasekhar Gontla on 04-Nov-2015 01:56


We tried a way to achieve this and it is working fine.

The way is

> Create 2 triggers of type object script (one is on before update (Ex: Trigger1) and another one is on after update ((Ex: Trigger2).

> In Trigger 1, get the related records count and share the value to next trigger using setSharedValue API.

> In Trigger 2, get the latest related records count and compare with shared value.

> If latest count is greater than shared value then it is attached otherwise it is detached.

Note: It will work if you update record (attach/detach using lookup field) through edit page. It will not work if you attach/detach in record details page as 'Before Update" trigger will not work on attach/detach action. It is a known limitation.

Find attached app xml to illustrate the same. Update the record in Emp object and check the Emp object-> Trigger->Log.

Thanks and Regards,


Posted by IramK on 04-Nov-2015 09:09

Thanks Chandu for your reply, I'll try it out and let you know if I have any questions.



Posted by IramK on 09-Nov-2015 05:41

Hello Chandu,

Thanks for the answer. I tried the above solution, however I was wanting it to work from the record details page rather than the new/edit page. I did try it out on the record details page but the trigger doesn't capture that unfortunately. Is there no other solution to this? Kindly let me know.


Posted by Chandrasekhar Gontla on 09-Nov-2015 06:00

Hi Iram,

I don't have any solution for that problem. :(

Please raise a request in Ideas section for "Working with Before Update" trigger on attach/detach action in record details page.

Thanks and Regards,


This thread is closed