copy attachment from RITM to approval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 03:25 AM
Hello Experts
We are trying to copy attachments from RITM to sysapproval table.
I have created below BR but unfortunately not working pls correct me,
Table :sc_req_item
When : After and Insert
Filter condition :
Item is "X"
Script :
(function executeRule(current, previous /*null when async*/ ) {
attachApproval();
function attachApproval() {
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sys_id', current.sysapproval);
gr.query();
while (gr.next()) {
GlideSysAttachment.copy("sysapproval_approver", gr.sys_id, "sc_req_item", current.sys_id);
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 05:01 AM
Hi @Brad Bowman ,
Thanks for the detailed Explaination.!
I want to achieve this for only two items only.
Item name - "X" and "Y"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 05:46 AM
I'm not sure why you wouldn't want to show approval record (parent) attachments for all approvals, but you could make the related list mis-leading by filtering it like this in the relationship query:
(function refineQuery(current, parent) {
var ritm = new GlideRecord('sc_req_item');
if (ritm.get(parent.sysapproval)){
if (ritm.cat_item.name == 'X' || ritm.cat_item.name == 'Y') {
current.addQuery('table_sys_id', parent.sysapproval);
} else {
current.addQuery('sys_id', ''); //no records are displayed
}
} else {
current.addQuery('sys_id', ''); //no records are displayed
}
})(current, parent);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 05:01 AM
Hi @akin9
What is the use case for this? To do this, need to write script which is not a best way. We can educate user to use the system and if possible avoid the customization.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 05:10 AM
Hello @Dr Atul G- LNG ,
Thanks for the reply!
We have item external user creation. and two level of approvals are there
If any user related documents attached then approver need to see those attachments.