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

this is the exact script 

function
onSubmit() {
   //Type appropriate comment here, and begin script below
   var securityGroup = g_form.getValue('Azure_AD_Security_Group');
   var attachmentCount = g_form.getAttachmentCount();
 
   if (!securityGroup && attachmentCount == 0) {
    g_form.addErrorMessage(
      'Please provide either a Azure AD Security Group or Attach the list of users to be added to the group.');
    return false;
  }
  return true;  
}

Hi @VinushaN0004809 

 

You are using the variable type attachments and you are trying to fetch it on the client side so the script is not working ,instead use GlideAjax for getting the attachment count on the record and you can glide the attachments table as well.

 

Hope that Helps!

PradeepReddyA
Tera Expert

Hi @VinushaN0004809 

 

Use an onSubmit Client Script to control whether a request can be submitted. Add conditions to check if at least one of the required fields has a value. If any field is populated, return true to allow submission; otherwise, return false to prevent the request from being ordered.

 

Please verify the the below link for how to restrict the submission.

 

 

Hope that Helps!

Rishi_11
Mega Sage

Hi @VinushaN0004809 ,

 

As others have suggested, an onSubmit() client script is the best way to do this. But yes users would have to click on the order button to for this validation to trigger. If you want to disable to order button itself, you might have use DOM which is not recommended. 

 

Please mark my response as helpful if this helped you.

 

Regards, 

Rishi.