hide Mandatory checkbox under portal settings using script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2025 06:36 AM
I have requirement if submitter authoorised selected as No , it should hide attachments , but as it was mandatory on the poratl settings level , how can i hide attachments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2025 06:48 AM
You need to create the catalog policy for this and make the necessary logic changes.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2025 07:21 AM
then don't make the attachment mandatory in portal settings.
Use onSubmit catalog client script and see the variable value and then make attachment mandatory
function onSubmit() {
//Type appropriate comment here, and begin script below
try {
var count = getRPAttachmentCount();
if (window == null) {
// portal
if (count == 0 && g_form.getValue('variableName') == 'yes') {
alert('You must add attachment before submitting this request.');
return false;
}
}
} catch (ex) {
// native view
var length = getSCAttachmentCount();
if (length == 0 && g_form.getValue('variableName') == 'yes') {
alert('You must add attachment before submitting this request.');
return false;
}
}
}
function getRPAttachmentCount() {
var length;
try {
length = angular.element("#sc_cat_item_producer").scope().attachments.length;
} catch (e) {
length = -1;
}
return length;
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2025 07:26 AM
@Ankur Bawiskar
But it should be mandatory on catalog item , but when sumitter field is selcted with no add attachments should get hided , hence preventing the user from submitting the request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2025 07:44 AM
you cannot hide that bottom attachment thing.
the only way is the approach I shared.
That will work for you.
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader