- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2022 01:35 AM
I want to create the related list(Relationship) on change table as approval-attachment and it should shows the attachments attached while approving and rejecting the change request.
Solved! Go to Solution.
- Labels:
-
Service Desk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2022 04:45 AM
this worked for me
CHG -> has 1 file
Approval record has 1 file
Total 2 records shown in related list
(function refineQuery(current, parent) {
// Add your code here, such as current.addQuery(field, value);
// get the approval records for this CHG
var app = [];
var gr = new GlideRecord("sysapproval_approver");
gr.addQuery("sysapproval", parent.getUniqueValue());
gr.addQuery("source_table", "change_request");
gr.query();
while(gr.next()) {
app.push(gr.getUniqueValue());
}
app.push(parent.sys_id.toString());
current.addQuery("table_sys_id" ,"IN", app.toString());
})(current, parent);
Please mark my response as correct and close the thread
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2022 06:19 AM
Hi Ankur,
It is working. Thank you.
I have another one doubt or issue,
if we use the glidesysattachment.copy method to copy attachment it creates the duplicate records so we prefer the related list solution.
Earlier
I was trying to copy the attachment using glidesysattachment.copy() and then I am comparing with the attachment table , but in the code if we provide specific file name then only the code gets run otherwise not.
Below is the code I am running on approval table:
If I comment the line - gr.addQuery('file_name','testdata.txt'); then creates the duplicate file on change record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2022 09:02 AM
please post a separate question for this
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2022 09:08 AM
Yes, sure.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2022 01:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2022 02:41 AM
Hi Saurabh,
I don't need related approvals,
I need the attachments if some approver attached attachment while the approving the request or rejecting request then that attachment I need to copy on change record, I tried by using the "GlideSysAttachment.copy" method but it copies the all attachments which results in duplicates records.
