- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2021 10:19 AM
Recently Servicenow added a new variable type named attachment and it works great. Here is my question. When that variable is used on the catalog item , it attaches the file in the work note in the case created. That location is different from where the files is attached when using the paper clip . Is here a way to make the new variable attachment add the file to the top of the case as when you use the paper clip?
Solved! Go to Solution.
- Labels:
-
Case and Knowledge Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2021 08:04 AM
I have shared working solution in this link below
Disable ZZ_YY prefix from attachment when added through record producer
Adding the same here for your reference:
1) I created Async After Insert BR on the sc_req_item table
2) Script as this
a) Remove the ZZ_YY
b) Then use the Copy Attachment functionality
(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();
if (gr.next()) {
gr.table_name = current.getTableName();
gr.update();
new global.VariableUtil().copy(gr.sys_id, current.getTableName(), current.sys_id);
}
})(current, previous);
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
‎03-17-2021 07:43 AM
Are you using the native UI, Service Portal, or both? Do you have a script to make the variable mandatory under these conditions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2021 07:56 AM
I am using both , I have created catalog UI policy with the catalog UI poly actions to make the variable mandatory . I want to say that I like the look of the new attachment variable but not sure how to properly use the script you provided me with. What table to use.
var attach = new GlideRecord('sys_attachment'); attach.addQuery('table_name', 'ZZ_YYsc_req_item'); attach.addQuery('table_sys_id', current.sys_id); attach.query(); while(attach.next()){ attach.table_name = 'sc_req_item'; attach.update();
Thank you for your help on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2021 08:07 AM
This will run after your request form is submitted, and after the RITM has been created, so it runs on the sc_req_item table
I have an onSubmit Catalog Client script that works well in the native UI. It calls a GlideAjax Script Include, then prevents submission if there is not an attachment, so you could apply your criteria to that, but there are different issues with the Service Portal. Nothing insurmountable, but it sounds like it's best to use the Business Rule in your case, and hit me up later if you decide to go back to the paper clip icon.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2021 08:04 AM
I have shared working solution in this link below
Disable ZZ_YY prefix from attachment when added through record producer
Adding the same here for your reference:
1) I created Async After Insert BR on the sc_req_item table
2) Script as this
a) Remove the ZZ_YY
b) Then use the Copy Attachment functionality
(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();
if (gr.next()) {
gr.table_name = current.getTableName();
gr.update();
new global.VariableUtil().copy(gr.sys_id, current.getTableName(), current.sys_id);
}
})(current, previous);
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-04-2024 04:12 PM
hello ankur,
i have the same query related to attachment variable. The attachment is getting downloaded by admin and not by any ITIL User. Is there any possible troubleshooting i can do to find the cause. I have posted one question also.
Re: Attachment not able to download from RITM - ServiceNow Community