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?

10 REPLIES 10

Ankur Bawiskar
Tera Patron

@VinushaN0004809 

screenshots please

VinushaN0004809_0-1775730542493.png

 

Tanushree Maiti
Tera 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.

 

 

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