catalog task variable

eyal abu hamad
Mega Sage

Hello,
I want when to change variable from mandatory to not mandatory when state of the catalog task changes to "pending".

eyalabuhamad_0-1698320845622.png

is there any way to change the variables that came from catalog item ?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@eyal abu hamad 

you can use normal onChange client script on sc_task and use this script

Don't use catalog client script

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue === '') {
		return;
	}

	if(newValue.toString() == '-5'){
		g_form.setMandatory('variables.variableName', true);
	}
	else{
		g_form.setMandatory('variables.variableName', false);
	}
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@eyal abu hamad 

you can use normal onChange client script on sc_task and use this script

Don't use catalog client script

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue === '') {
		return;
	}

	if(newValue.toString() == '-5'){
		g_form.setMandatory('variables.variableName', true);
	}
	else{
		g_form.setMandatory('variables.variableName', false);
	}
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

thanks !!

Satyapriya
Mega Sage

You can write a UI policy for that and provide coditions i.e state changes to pending Then apply the UI policy action as per your need.

please mark it as helpful and accept it as solution if it is helpful for you.

Regards,

Satyapriya