- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2019 07:47 AM
I have an ritm in which i want attachment variable , i made type specification "macro" and called attachment in reference
but am unable to make it mandatory
pls help me out in this
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2019 07:59 AM
You cannot make the attachment variable mandatory. If attachments is always mandatory there is a checkbox available in Madrid to when creating the item to make attachments mandatory. If it is based on conditions for other variables you will need to write an onSubmit client script to prevent from submitting without the attachment.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2019 07:59 AM
You cannot make the attachment variable mandatory. If attachments is always mandatory there is a checkbox available in Madrid to when creating the item to make attachments mandatory. If it is based on conditions for other variables you will need to write an onSubmit client script to prevent from submitting without the attachment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2019 08:30 AM
Hi,
You can not make variable mandatory but you can check if attachment is attached or not. If there is not attachment you can pop message for attachent.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2019 09:19 AM
Hello Amaresh,
function onSubmit() {
var cat_id = gel('sysparm_item_guid').value; //or you can use g_form.getUniqueValue();
// you can make call of script include here. as glide record in not recommended in client script
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "sc_cart_item");
gr.addQuery("table_sys_id", cat_id);
gr.query();
if (!gr.next()) {
if(g_form.getValue('unblock') == true){
alert("You must attach a screen shot of the website with the ticket before proceeding.");
}
return false;
}
check out this blog :
https://servicenowtips.tumblr.com/post/12902061888/service-catalog-mandatory-attachments
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade