how to set Attachment Mandatory in Service portal cataloque item

Srinivasu2
Tera Contributor

Hi Community,

 

How to set Service portal catalogue item Attachment symbol mandatory

 

If i select data master  is Customer and operation is New,  Attachment symbol should be mandatory in Service portal catalogue item

 

Please suggest how to do that?

 

Regards,

Srinivasu 

7 REPLIES 7

Shruti
Mega Sage
Mega Sage

Hi,

Create a onSubmit client script 

Please refer below script and replace the variable names as per the requirement

function onSubmit() {

//Works in non-portal ui
var data_master_val = g_form.getValue('data_master');

var opr_val = g_form.getValue('operation');

if (data_master_val == 'Customer' && opr_val == 'New ') {

try {
var attachments = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none') {
alert('Please attach the document before submitting this request.');
return false;
}
}

//For Service Portal
catch (e) {
var count = getSCAttachmentCount();
if (count <= 0) {
alert('Please attach the document before submitting this request.');
return false;
}

}

}
}

Abhijeet_Pawar
Tera Guru

Hello @Srinivasu2, on the catalog item creation form, there is a portal setting section from there you can make attachments mandatory without writing a single line code.

regards,

Abhijeet

Ankur Bawiskar
Tera Patron
Tera Patron

@Srinivasu2 

this is required for native or portal?

Check my blog and enhance the script as per your requirement

Verify Mandatory Attachments Count on Catalog Item 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Harish KM
Kilo Patron
Kilo Patron

Hi you need to follow the link to implement the same.Check below URL

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0743672

Regards
Harish