Populate phone type variable based on location table parent field .

suha2
Tera Contributor

Hi All,

In catalog items, I have a work location variable referencing the location table. If the parent field in the location table is set to 'United Kingdom,' then the phone type variable should be visible on the catalog items form. Does anyone have an idea on how to achieve this?

 

suha2_0-1706000172065.png

 

7 REPLIES 7

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @suha2 

 

What type of variable is phone type? 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

@Dr Atul G- LNG 

phone type variable  is select box  type.

 

suha2_0-1706002491428.png

 

Hi @suha2 

 

I was trying to do with UI policy but it is not possible as dotwalk is not available, Please follow @Ankur Bawiskar script for this. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron
Tera Patron

@suha2 

you need to use onChange + getReference callback for this

something like this, I hope you can enhance it further

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

	var ref = g_form.getReference('work_location', callBackMethod); // give correct variable name here

}

function callBackMethod(ref){
	if(ref.country.toString() == 'United Kingdom')
		g_form.setDisplay('phoneTypeVariable', true); // give correct variable name here
	else
		g_form.setDisplay('phoneTypeVariable', false); // give correct variable name here
}

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