Update comments with attachment added

pushparaj
Mega Contributor

Hi all,

I want comments to be updated in requested item when an attachment is attached with the details like :

Attachment added to $RITMNumber$.

File name : $Filename$ by $Createdby$ at $created$

I would prefer a insert Business rule. So when attachment is added from portal also it would trigger.

so should i write the business rule on "sys_attachment" table or "sc_req_item" table.

Note: sys_attachment has no reference fields and just saving attachment with the table name in which its added into.

also can you please help me with the script for Business rule.to attain the infomation in comments like item number date etc..

Thank you .

1 ACCEPTED SOLUTION

Deepak Kumar5
Kilo Sage

Add a insert BR in Attachment Table with condition that current.table_name == "sc_req_item"


BR:


updateRecordForAttachment();  


function updateRecordForAttachment(){  


var gr = new GlideRecord(current.table_name);  


    if(gr.get(current.table_sys_id)){  


  gr.work_notes = "Attachment: " + current.file_name + " has been attached.";  


  gr.update();  


    }  


}  


View solution in original post

6 REPLIES 6

Jiya1
Kilo Contributor
Can you please suggest some solutions if I want to see the message in the sc_task if I add some attachment in the requested item.

Mike Foreman
Tera Contributor

This is a great solution but i'm trying it in Utah release and the script is not working on creation of a new record. I'm using it for attachments to sn_si_request, and even when i set it to before and after create it's only adding the comments for attachments when the sn_si_request record is created. Any thoughts on how to get it to work when the attachment is added to a record on create?