sys_attachment delete Business Rule runs only once when multiple attachments deleted

Bryan13
Tera Expert

I extended the User (sys_user) table and added some attachment related columns (to allow for download/deletion via the portal). I created a Business Rule to clear these fields when an attachment is deleted. This works fine when only one attachment is deleted. However if you delete multiple via "Manage Attachments", the business rule runs only once and only one of the attachments related columns are cleared.

Any ideas on what I need to do to catch each deletion?

bus-rule1.PNG

bus-rule2.PNG

bus-rule3.PNG

1 ACCEPTED SOLUTION

Hi Bryan,



Please use few code in your addQuery below.



gr.addQuery('table_sys_id', current.table_sys_id);



You are using if condition to check if sys_id matches and then update the record, that means you will be taking care only one record since var file_sys_id = current.sys_id.toString() will give you sys_id of current record. So, i think if you want to delete all the record based upon the table_sys_id then while loop should work without if/else condition in that.



In your else if condition you are using gr.gr.<variable name>. two times gr is not correct.



In file_sys_id == gr.resume_sys_id, is resume_sys_id a reference field which gives sys_id?



Hope this helps.


View solution in original post

5 REPLIES 5

Duh...user error on my part. After reviewing your answer a second time, I noticed this statement:



"In your else if condition you are using gr.gr.<variable name>. two times gr is not correct."



I don't know how many times I've looked at that script and never noticed the duplicate gr's.



I removed the extra gr and everything works now. Thanks and sorry to everyone for wasting your time...



user-error.PNG