I have set my business rule on sys_attachment table, so that when an attachment is updated on an incident record, i can fire my update incident rule to trigger operation on Incident table. I have tried below scripts but it is not working for me

Yama2
Kilo Contributor

condition = current.table_name == "incident"

When to run : After Insert/Update

(function executeRule(current, previous /*null when async*/ ) {
    var gr = new GlideRecord("incident");
    gr.addQuery("sys_id", current.table_sys_id);
    gr.query();
	gs.log("===>record exists", gr.next());
    while(gr.next()) {
		gs.log("===>record glide", gr);
		//fi = gr.getElement('isAttachmentUpdated'); 
		gr.setValue('isAttachmentUpdated', 'Updated'); //custom field isAttachmentUpdated
        gr.update();
    }

    // Add your code here

})(current, previous);

Note: I'm able to receive the "record exists" debug as "true" but not able to get the log inside while loop. Please help me understand what is the issue fix as the custom field (isAttachmentUpdated) on incident is also not getting updated.

 

 

1 ACCEPTED SOLUTION

Hello

If this has answered your question, kindly mark the comment as a correct answer so that the question is moved to solved list.

View solution in original post

20 REPLIES 20

Hello

If this has answered your question, kindly mark the comment as a correct answer so that the question is moved to solved list.