- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2023 12:47 AM
Hi ,
I have below requirement.
one of our clients asked to add a variable on my record producer form.
if end user attaches any attachment and submit the request. It is updating in worknotes or activity log but not on the header.
my requirement is whenever end users add any attachment he should be able to see on the request form header itself .
can someone help me how to add it on header of the request form instead of adding in activity log.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 12:54 AM
you didn't mention that in your question.
For that you need to use while loop in script
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "ZZ_YY" + current.getTableName());
gr.addQuery("table_sys_id", current.sys_id);
gr.query();
while (gr.next()) {
gr.table_name = current.getTableName();
gr.update();
new global.VariableUtil().copyAttachment(gr.sys_id, current.getTableName(), current.sys_id);
}
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2023 01:02 AM
so basically you want to copy the file from that attachment variable and add it to the header where normal attachments are shown?
If yes then below link has solution shared by me; enhance it further as per your requirement
Disable ZZ_YY prefix from attachment when added through record producer
Please ensure you update this line as the function has changed from copy to copyAttachment()
new global.VariableUtil().copyAttachment(gr.sys_id, current.getTableName(), current.sys_id);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2023 10:47 AM
I tried below post for my requirement. the attachment added in variable of type attachment was getting under activity log but not on the header.
Am i missing something.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2023 07:56 PM
You didn't copy the exact script.
Update your this line
gr.addQuery("table_name", "ZZ_YY" + current.getTableName());
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 12:49 AM
there are 3 attachment variables on my form. when i attach the attachments only one attachment was coming on the header on my target record.
Is there any restrictions for attachment variable count?