Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Force Mandatory Variable

Community Alums
Not applicable

Hi Connections,

 

I have a variable. Safe Updating with three choices, when safe updating is selected, I want to push user to fill any ONE of the below variables, Standard User Role OR Safe Manager Role.  How can I achieve this. any suggestions... to show that two variables i have created UI policy to appear on the form when safe updating is selected....

 

Rafmine_0-1699483036531.png

 

appreciate any help.

 

Best Regards,

Rafmine.

 

 

 

18 REPLIES 18

Hi @Community Alums ,

 

Plz try below code. Here instead of AND condition we will use OR condition

 

function onSubmit() {
   //Type appropriate comment here, and begin script below

   var abc = g_form.getValue('add_user_safe');
   var stdRole = g_form.getValue('standard_user_role');
   var safeMgrRole = g_form.getValue('safe_manager_role');


   if(abc == 'true' && (stdRole == '' || safeMgrRole == '')){
	alert('Kindly fill the Standard User Role Value & Safe Manager Role Value');
	return false;
   }else{
	return true;
   }
   
}

 

Thanks,

Danish

 

Community Alums
Not applicable

Hi Danish,

 

I use the below code but my no luck...

 

Rafmine_0-1699506579545.png

don't know where i'm moving wrong...

Hi @Community Alums ,

 

Safe updating must be a label type variable right?

Can u send me screenshots of the variables u have created in the backend?

 

Thanks,

Danish

 

Community Alums
Not applicable

Hi Danish,

 

Kindly find the below Screenshot as requested...

 

Rafmine_0-1699507274467.png

 

@Community Alums ,

 

Thanks for the snip. What is the backend name of Add user to safe?

I presume on selection of that option u are getting those 2 fields right.

 

Can u let me know the backend value for Add user to safe.

Screenshot of multiple choice of safe updating variable.

 

Thanks,

Danish