Remove alert message

Mehar Naaz
Tera Contributor

MeharNaaz_0-1693890315689.png

Currently this alert is pop on selection of every field in the form, before submitting the form. I want it to pop up on only 1 field when the form is submitted.

any solution to my query?

2 ACCEPTED SOLUTIONS

This script will generate an alert if no Locations is submitted, since you only check if they are equal.

Maybe you should add a check so see if they contain a value first, before evaluating if they are the same?

function onSubmit() {
      var primaryLocation = g_form.getValue('u_primary_location');
    var secondaryLocation = g_form.getValue('u_secondary_location');
  if (primaryLocation || secondaryLocation) {  // added check so see if any location contains a value
        if (primaryLocation == secondaryLocation) {
            alert('Primary Location and Secondary Location cannot be same');
              return false;
        }
  }
}

View solution in original post

MrGupta__
Tera Expert

Hi @Mehar Naaz,

Open the particular form and configure the client script (onChange or onSubmit) for that and check the condition.

Regards,

Himanshu

View solution in original post

8 REPLIES 8

OlaN
Giga Sage
Giga Sage

Hi,

What are the conditions for this script to launch ?

Mehar Naaz
Tera Contributor

it should be on submit  of the form.

Ankur Bawiskar
Tera Patron
Tera Patron

@Mehar Naaz 

did you identify from where this is coming? that will help you understand the script and update the logic

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

MrGupta__
Tera Expert

Hi @Mehar Naaz,

Open the particular form and configure the client script (onChange or onSubmit) for that and check the condition.

Regards,

Himanshu