what is difference of Set Mandatory and Is Mandatory

ajay56
Kilo Contributor

I want the exact difference in clearly.

      Thanks in advance

4 REPLIES 4

Chaitanya Redd5
Tera Guru

Hi Ajay,

setMandatory function sets the field as mandatory or non mandatory whereas isMandatory function checks whether the field is mandatory or not returns Boolean value. Sample codes with comments are below:

g_form.isMandatory('field_name');// returns true is field is mandatory and false if the field is non mandatory

g_form.setMandatory('field_name',true);//sets the field as mandatory.

g_form.setMandatory('field_name',false); //sets the field ad non mandatory.

Kindly mark my answer as Correct and Helpful based on the Impact.

Regards,

Chaitanya

yes, that's correct..

function onLoad() {
g_form.setMandatory('caller_id',false);
g_form.setMandatory('description',true);
g_form.isMandatory()
}

g_form.isMandatory('field_name'); it is showing false on mandatory fields also??

 

Prateek kumar
Mega Sage

Here is the official doc for glideform API.

https://developer.servicenow.com/app.do#!/api_doc?v=newyork&id=r_GlideFormIsMandatory_String

https://developer.servicenow.com/app.do#!/api_doc?v=newyork&id=r_GlideFormSetMandatory_String_Boolea...

 


Please mark my response as correct and helpful if it helped solved your question.
-Thanks