
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2019 12:07 PM
Hi,
I have a variable (type = CheckBox) that when it is checked, I do not want the attachments on the SC item to be mandatory, otherwise if the CheckBox is not checked, it should be mandatory. I can't figure out how to achieve this. Can someone provide the best practice solution/suggestion please?
Thanks!
Solved! Go to Solution.
- Labels:
-
Request Management
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2019 07:38 AM
Are you using this on the platform, service portal, or both? At this time, the ootb 'Attachment Mandatory' feature is a one or nothing kind of function, meaning there is no condition to check a variable, hopefully they'll put this in, in a future release. I've used the following blog with success on multiple instances, and it works for both the Service Portal and platform.
Make sure you add the UI Script and JS theme, and then you can create multiple catalog client scripts utilizing this code for consistency:
https://www.servicenowelite.com/blog/2017/5/12/service-portal-require-attachments
Here's an example I used in the past to check a variable, just make sure the UI Script and JS theme is in place before trying to use the Catalog Client Script:
var type = g_form.getValue('uvar_typeOfRequest');
try { //Works in non-portal ui
if (type =='infochange') {
var attachments = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none') {
g_form.addErrorMessage("Please attach the Informational Change Template to this request");
return false;
}
}
} catch(e) { //For Service Portal
var count = getSCAttachmentCount();
if(count <= 0 && type == 'infochange') {
g_form.addErrorMessage("Please attach the Informational Change Template to this request");
return false;
}
}
If my response was helpful, please mark as Helpful and consider setting the reply as the Correct Answer if it best answered your question, thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2019 07:38 AM
Are you using this on the platform, service portal, or both? At this time, the ootb 'Attachment Mandatory' feature is a one or nothing kind of function, meaning there is no condition to check a variable, hopefully they'll put this in, in a future release. I've used the following blog with success on multiple instances, and it works for both the Service Portal and platform.
Make sure you add the UI Script and JS theme, and then you can create multiple catalog client scripts utilizing this code for consistency:
https://www.servicenowelite.com/blog/2017/5/12/service-portal-require-attachments
Here's an example I used in the past to check a variable, just make sure the UI Script and JS theme is in place before trying to use the Catalog Client Script:
var type = g_form.getValue('uvar_typeOfRequest');
try { //Works in non-portal ui
if (type =='infochange') {
var attachments = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none') {
g_form.addErrorMessage("Please attach the Informational Change Template to this request");
return false;
}
}
} catch(e) { //For Service Portal
var count = getSCAttachmentCount();
if(count <= 0 && type == 'infochange') {
g_form.addErrorMessage("Please attach the Informational Change Template to this request");
return false;
}
}
If my response was helpful, please mark as Helpful and consider setting the reply as the Correct Answer if it best answered your question, thank you!