
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 06:07 AM
There are a bazillion questions/posts on how to make an attachment mandatory based on a variable, but non (that I can find) to do the opposite.
I have a catalog item with this checked:
I always need an attachment on this particular item.... unless there is 1 checkbox checked. If that checkbox is checked, then I need to make attachments NON-mandatory.
Anyone out there know how to accomplish this?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 07:13 AM
I need that checkbox checked. I'll just chalk it up to the fact that this cannot be done, keeping that checkbox checked. It appears there is no way at all possible to keep it checked and make the form not need an attachment based on a variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 06:14 AM - edited 11-28-2022 06:41 AM
Hello @xiaix ,
this article is going to solve your problem.Follow the steps correctly and then you will be able to achieve it .
1) Add a UI script
2)Add a JS theme to your portal on which your catalog item is there
3)Write an client script - Use the script given in third step of the article (onsubmit) and add your if logic to that script like below to check your variable value
function onSubmit() {
//Works in non-portal ui
try {
var attachments = document.getElementById('header_attachment_list_label');
if ((attachments.style.visibility == 'hidden' || attachments.style.display == 'none' ) && g_form.getValue('your_checkbox_name') ==false) {
alert('You must attach the completed form before submitting this request.');
return false;
}
}
//For Service Portal
catch(e) {
var count = getSCAttachmentCount();
if(count <= 0 && g_form.getValue('your_checkbox_name') ==false) {
alert('You must attach the completed form before submitting this request.');
return false;
}
}
}
Hope this helps
Mark my answer correct if this helps you
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 06:17 AM
@Mohith DevatteI challenge you to read my post. I mean really read it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 06:29 AM - edited 11-28-2022 06:30 AM
@xiaix i read it by the way and you have to uncheck that check box and do it through script because if you use that check box we cant make it non mandatory so through script you need to handle it and thats why i proposed the above solution in the article

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 07:13 AM
I need that checkbox checked. I'll just chalk it up to the fact that this cannot be done, keeping that checkbox checked. It appears there is no way at all possible to keep it checked and make the form not need an attachment based on a variable.