Need to Set a value on single line text variable based on other variable selected choice.

varma2
Mega Sage

Hi All,

 

We have multi choice variable called (service ) in that we have multiple choices. if the choice contains 'SP', we need to set a other variable single line text value as ''123'', if the choice contains 'ORACLE,' we need to set a other variable single line text value as ''456'',.

 

Please suggest,

Thanks All.

 

1 ACCEPTED SOLUTION

Hi,

update as this

function onChange(control, oldValue, newValue, isLoading) {

	if (isLoading || newValue == '') {
		return;
	}

	var service = g_form.getValue("vic_ServiceTier");

	if(service.indexOf('SQL') > -1){
		g_form.setValue("vic_PortNumber", "1433");
	}
	else if(service.indexOf("Oracle") > -1){
		g_form.setValue("vic_PortNumber", "1521");
	}

}

Regards
Ankur

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

View solution in original post

7 REPLIES 7

Hi Ankur,

 

Thanks for reply,

Below script i have tried. below script it has mentioned equal but it should contains,

 

 

 

function onChange(control, oldValue, newValue, isLoading) {

if (isLoading || newValue == '') {
return;
}

var service = g_form.getValue("vic_ServiceTier");

if(service == 'SQL'){

g_form.setValue("vic_PortNumber", "1433");

}

if(sevice == "Oracle"){

g_form.setValue("vic_PortNumber", "1521");

}

}

 

Please suggest.

Hi,

update as this

function onChange(control, oldValue, newValue, isLoading) {

	if (isLoading || newValue == '') {
		return;
	}

	var service = g_form.getValue("vic_ServiceTier");

	if(service.indexOf('SQL') > -1){
		g_form.setValue("vic_PortNumber", "1433");
	}
	else if(service.indexOf("Oracle") > -1){
		g_form.setValue("vic_PortNumber", "1521");
	}

}

Regards
Ankur

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

@varma

Thank you for marking my response as helpful.

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

Regards
Ankur

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