Dynamically remove reference qualifier onChange script

dougpenta
ServiceNow Employee

Is there a way to remove a reference qualifier acting on a Service Catalog variable when a user changes the value on another variable?

 Ex.

 

Field A (True/False)

Field B (Reference field)

 

if(Field A changes)

Field B (remove reference qualifier)

2 REPLIES 2

Ankur Bawiskar
Tera Patron

@dougpenta 

you can use advanced ref qualifier which depends on other variable.

using client script not possible to change reference qualifier

You are ServiceNow employee, you can check internally with the product team if you wish to.

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Tanushree Maiti
Mega Sage

You can use an if statement as using the javascript: prefix enables that field to accept JavaScript.

If it's a bit more complex, then you can use a Script Include as well.

So use if statement , it's like:

 

javascript&colon; var queryVarB; if (current.variables.variable_A = = True) { queryVarB="<encodedQuery1>"; } else { queryVarB="encodedQuery2"; } queryVarB; 

 

Please mark this response as Helpful & accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: