Need business rule to copy RITM attachments to respective sctask
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2023 12:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2023 06:05 AM
Hi,
The attachments are kept in sys_attachment. However, what yo don't want to do is just create a process where you iterate through the attachments doing inserts. Here is the code to take care of doing that copy task. I expect that you will use it in an after insert business rule on sc_task.
var attachments = new GlideRecord("sys_attachment");
var task_attach = new GlideSysAttachment();
attachments.addQuery("table_name", "sc_req_item");
attachments.addQuery("table_sys_id", current.parent.sys_id);
attachments.query();
if (attachments.getRowCount() > 0) {
attachments.next();
task_attach.initialize();
task_attach.copy("sc_req_item", attachments.table_sys_id, "sc_task", current.sys_id);
}
I copied this from a script that I use to copy attachments from incidents to change requests so there may be some fine tuning needed.
:{)
Helpful and Correct tags are appreciated and help others to find information faster
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2023 06:26 AM
Hi @bhupendrapareek ,
You can use below code in Business rule.
GlideSysAttachment.copy('sourcetable','sys_id','destinationtable','sys_id');
Please refer the below links.
If my answer resolves your issue then please mark it as correct and helpful.
Regards,
Namrata
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2023 07:41 AM
Hi Namrata ,
i tried with below logic in "After BR" on sys_attachment table .but we are getting multiple-cloned attachments in sctask form for every sctask update (worknotes/add. comments) even though i have put restrictions in BR (yellow coloured) , still BR getting triggered , Any suggestions on that???
and second case is , for every attachment added on RITM , duplicate attachments are created on sctask.
please advise on it as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2023 11:34 AM
Hi,
You need to have the rule as after insert on sc_task
:{)
Helpful and Correct tags are appreciated and help others to find information faster