- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 08:33 AM
Hello Team,
My requirement is to make and attachment mandatory based on the value of any catalog variables. I saw many proposed articles in community to do it via DOM manipulation technique.
where this technique is not good to use as per ServiceNow recommendation. Is there any other possible way to make this work ?
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2023 08:41 AM
I don't know of an alternate approach that works with Service Portal. You can make attachment variables show at the top of the form instead of the activity stream by creating an async, Insert Business Rule on the sc_req_item table. The script looks like this:
(function executeRule(current, previous /*null when async*/) {
var attach = new GlideRecord('sys_attachment');
attach.addQuery('table_name', 'ZZ_YY' + current.getTableName());
attach.addQuery('table_sys_id', current.sys_id);
attach.query();
while(attach.next()){
attach.table_name = current.getTableName();
attach.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 10:12 AM
Create a variable that has the type of attachment, then make that variable mandatory based on another variable(s) via Catalog UI Policy or Catalog Client Script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 11:03 PM
I tried implementing this but the attachment is not shown on top of the Request item. The attachment is shown in variables editor.
Can't we use the Glide Form API or a different approach for the solution?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2023 08:41 AM
I don't know of an alternate approach that works with Service Portal. You can make attachment variables show at the top of the form instead of the activity stream by creating an async, Insert Business Rule on the sc_req_item table. The script looks like this:
(function executeRule(current, previous /*null when async*/) {
var attach = new GlideRecord('sys_attachment');
attach.addQuery('table_name', 'ZZ_YY' + current.getTableName());
attach.addQuery('table_sys_id', current.sys_id);
attach.query();
while(attach.next()){
attach.table_name = current.getTableName();
attach.update();
}
})(current, previous);