We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to redirect to another form on onChange of field.

Aakash007
Tera Contributor

How to open a new form in new tab on change of field value of a form.

1 ACCEPTED SOLUTION

@Aakash007 

g_navigation won't work in portal.

you need to use top.window

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


	if (newValue == 'some value'){
		var redirectURL = 'https://something.service-now.com/itsp?id=sc_catalog_item&sys_id=something'; 
		top.window.open(redirectURL, "_blank");
	}
}

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

 

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

View solution in original post

6 REPLIES 6

Aakash007
Tera Contributor

Hi @Ankur Bawiskar 

 

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


if (newValue == 'some value'){
var redirectURL = 'https://something.service-now.com/itsp?id=sc_catalog_item&sys_id=something'; 
g_navigation.open = redirectURL ;

@Aakash007 

g_navigation won't work in portal.

you need to use top.window

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


	if (newValue == 'some value'){
		var redirectURL = 'https://something.service-now.com/itsp?id=sc_catalog_item&sys_id=something'; 
		top.window.open(redirectURL, "_blank");
	}
}

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

 

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