- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 08:28 AM
Hi all,
I have one catalog item and it has one variable called "has_approval" and its type is "checkbox". If any user selects that checkbox, then the attachment should be mandatory. If the user selects the check box and if he didn't attach the attachment, then a pop up should show like "Please attach the attachment".
Can you please tell me how we should write the script.
Thank you
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 06:36 AM
Hi @Raghavendra ,
Please refer this thread it may help you. Verify Mandatory Attachments Count on Catalog Item
Kindly mark correct and helpful if Applicable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 10:07 AM
I would suggest adding a variable with the type of Attachment to your Catalog Item, then with a simple UI Policy you can make this variable mandatory when the checkbox value = true. This is the simplest approach and works both in the native UI / Service Catalog and the Service Portal. Here is an article detailing the other ways to make an attachment mandatory

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 10:09 AM
Hello @Raghavendra
Below are the links to some previous community posts which will help you in achieving this:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 10:29 AM
Hi @Raghavendra ,
You can write an OnSubmit Client script and use below code
function onSubmit() {
var attachment = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none' ) {
alert('There is no attachment');
return false;
}
Please mark correct if my response has solved your query.
Cheers,
Mohammed Basheer Ahmed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 10:21 PM
@ basheer
Hi
Thanks for tyour reply,I tried with your code but when i click on the check box and submit the catalog item.I'm getting the below error.
onSubmit script error: TypeError: Cannot read properties of null (reading 'getElementById'):
function () { [native code] }
I'm attaching the screen shot of the error