Open a link in new tab

Haribabu1
Tera Contributor

Hello,

 

When I select the checkbox variable of a record producer in the service portal, it needs to be an open link in a separate tab.

note: Can we achieve this without DOM?

 

Thanks in advance

 

1 ACCEPTED SOLUTION

@Haribabu1 

use this onChange catalog client script on that variable

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

	var url = '/sp?id=sc_cat_item&sys_id=recordProducerSysId'; // give here your portal name and the record producer sysId
	if (newValue == "your value to compare") {
		try{
			if(window != null)
				g_navigation.open(url, '_blank');
		}
		catch(ex){
			top.window.open(url,"_blank");
		}
	}
}

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

6 REPLIES 6

The code Ankur gave has no dom manipulation, its good.

-Anurag

@Haribabu1 

yes, the script I shared will run on both native+portal, UI Type - ALL. Ensure Isolate Script is false for your client script

where are you planning this to run? native or portal

If only native then use this line

				g_navigation.open(url, '_blank');

If only portal then use this line

top.window.open(url,"_blank");

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