How to make attachment not mandatory based on subcategory in single catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 06:23 AM
Hi all,
I created a custom catalog item (Record producer) called " Report an issue" in this catalog item we have a variable called "subcategory" which is a reference type of subcategory table. For this catalog item we made the attachments are mandatory by the mandatory attachments checkbox. However, the requirement is to make the attachment not mandatory only for single subcategory in this catalog item
How to configure this so that attachment is not mandatory only for single subcategory.
please help...
thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 07:24 AM
Hi,
I would suggest do not make it mandatory on variable level. Instead use 'catalog ui policy' to make mandatory false on a certain condition.
Select 'reverse' if false in ui policy. This way it will be mandatory true on all other conditions
//Please mark this correct if it helped.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 07:53 AM
if it is a variable on the form, I can use the catalog ui policy but it is not a variable in the catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 07:44 PM
you can do this
1) create a variable of type file attachment
2) then make it mandatory based on the value you want
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
09-21-2023 11:51 PM
Hi ankur,
I created a variable of attachment type but the attachement added are not showing up on the case but I can find the attachment in the sys_attachment table..I tried the below BR to show the attachments in the case header but it is not working
(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();
new global.VariableUtil().copyAttachment(gr.sys_id, current.getTableName(), current.sys_id);
gr.update();
}
})(current, previous);