either one of the field is not filled ...block the order

VinushaN0004809
Tera Contributor

either the security group or attachment needs to be filled in. So I would need 1 of the 2 to be filled in before they can click order button?

8 REPLIES 8

Ankur Bawiskar
Tera Patron

@VinushaN0004809 

screenshots please

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

VinushaN0004809_0-1775730542493.png

 

Tanushree Maiti
Kilo Patron

Hi @VinushaN0004809 

 

To make sure users either select a Security Group variable or upload a file in Catalog item, you can use an onSubmit Catalog Client Script to validate that at least one of these conditions is met.

 

You need to click order button ,so that onsubmit gets triggered.

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

function onSubmit() {

var securityGroup = g_form.getValue('security_group');
var attachmentCount = g_form.getAttachmentCount();

if (securityGroup && attachmentCount == 0) {
g_form.addErrorMessage(
'Please provide either a Security Group or an Attachment before submitting.'
);
else if (!securityGroup && attachmentCount > 0)
else if (securityGroup && attachmentCount >0)
else {
alert('Please provide either a Security Group or an Attachment before submitting.');}


return false;
}
return true;

}

i wrote above script but its not working for attachments