I want to delete the attachment of RITM if I delete the attachment from REQ. I have already used some code to copy attachments of RITM and REQ.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2022 04:43 AM
I had a requirement where I had to copy the attachments of RITM into REQ. And also If I delete the attachment from REQ the attachments from the respective RITM should also get deleted.
I have applied some Business Rule but it is deleting the other attachments which are getting attached.
var gr = new GlideRecord("sys_attachment");
var req = new GlideRecord('sc_request');
if (req.get(current.table_sys_id)) {
gr.addEncodedQuery("table_name=sc_req_item" + "^file_name=" + current.file_name);
gr.query();
while (gr.next()) {
gr.deleteRecord();
}
}
Can somebody help with the code?
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2022 11:41 PM
Hi,
the above BR is before delete and has nothing to do with your testing since it will run only on deletion and not when new file is added to RITM
You need to debug the use case
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader