Check if a field exists in a record producer

jonndoe
Kilo Contributor

Hi guys,

I'm new to Servicenow and probably not sure if I'm asking this question correctly so please bear with me.    

There's a record producer form in our instance that has a checkbox which only displays when a user selects a particular option from a dropdown list. Therefore, the checkbox is not always available for user inputs so I'm tasked with writing a catalog client script to check if the checkbox is available and if it's available run a specific function. For me to achieve this I want to check if the checkbox is present on the form at the time of submitting and wondering if anyone can show me how this could be done?

My function looks like below at the moment and it's missing the bit that checks for the existence of the field.

function onSubmit() {

  var terms = g_form.getValue('u_terms_conditions');

  if (terms === false) {  

    alert('Terms and conditions cannot be empty);

    return false;  

  }

}

Thanks in advance

JD

1 ACCEPTED SOLUTION

sergiu_panaite
ServiceNow Employee
ServiceNow Employee

I would replace:



if (terms === false)



with



if (terms)


View solution in original post

3 REPLIES 3

sergiu_panaite
ServiceNow Employee
ServiceNow Employee

I would replace:



if (terms === false)



with



if (terms)


Sharique Azim
Mega Sage

Hi Jon,



can you use 'true' instead?


jonndoe
Kilo Contributor

Thank you both for your swift replies.