- 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-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
11-15-2023 12:22 PM
Hi Ankur,
Thank you for the script, I have found it very helpful.
The only issue I have is that the attachment is appearing twice on the request.
Do you know why this would be happening?
Many Thanks
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 01:11 PM
Hi Ankur,
Thank you for the script, I have found it very helpful.
The only issue I have is that the attachment is appearing twice on the request.
Do you know why this would be happening?
Many Thanks
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2023 01:02 AM
Hi @Are Kaveri ,
Posting the existing solution provided on Community to resolve your issue
Disable ZZ_YY prefix from attachment when added through record producer
I hope this helps you
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Uday