- 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 12:23 PM
Yes, change the table name in 2 places in the Business Rule script (once with the ZZ_YY, and once without per the sc_req_item example, then change the Business Rule to run on the sn_hr_core_case_workforce_admin table instead of sc_req_item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2021 08:39 PM
yes please change it as I have shared in my script if you are referring that.
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-23-2023 02:56 PM
If anyone else is seeing this in 2023, the VariableUtil.copy() method is now VariableUtil.copyAttachment(). so you'll need to modify this line from:
new global.VariableUtil().copy(gr.sys_id, current.getTableName(), current.sys_id);
to:
new global.VariableUtil().copyAttachment(gr.sys_id, current.getTableName(), current.sys_id);
Not a huge fan of this functionality either, but this will make the BR above work again.