UI Action to open portal page

Jamsta1912
Tera Guru

Hello all,

A colleague created a UI action on the 'ticket' form, which opens a service portal page when clicked. It passes the sys_id of the current record, as a parameter. The code in the UI Action is this:

function selectStandardChange(){
	var url = 'sp?id=request_standard_change&sysparm_domain_restore=false&sysparm_stack=no&ticket_sys='+g_form.getUniqueValue();
	window.open(url, "_self");
	return false;
}

And, we have 'selectStandardChange()' in the 'OnClick' field.

This works perfectly. But, we're trying to create a similar UI Action to open a different service portal page. The UI Action is exactly the same, except that the OnClick function has a slightly different name, and we're referencing the other service portal page:

function selectStandardChangeWD(){
	var url = 'sp?id=request_standard_change_webdev&sysparm_domain_restore=false&sysparm_stack=no&ticket_sys='+g_form.getUniqueValue();
	window.open(url, "_self");
	return false;
}

But, this one doesn't work. The UI Action is visible on the form, but when clicked the service portal page does not open. The OnClick function is definitely being called (I put an alert in before the 'window.open' line to test that).

More bizarrely, if we copy the original UI Action (do an Insert) the new UI Action also does not open the page, even though the original does and is exactly the same. Any thoughts on what's going on here?

Thanks

Jamie

1 ACCEPTED SOLUTION

James Foot
Kilo Expert

Replace

window.open(url, "_self");

with

g_navigation.openPopup(url);

 

Final code should look like this:

function selectStandardChangeWD(){
	var url = 'sp?id=request_standard_change_webdev&sysparm_domain_restore=false&sysparm_stack=no&ticket_sys=' + g_form.getUniqueValue();
	g_navigation.openPopup(url);
	return false;
}

View solution in original post

7 REPLIES 7

Paul Curwen
Giga Sage

Is the Client checkbox ticked on your UI Action?

If not 'window.open' won't be recognized

***If Correct/Helpful please take time mark as Correct/Helpful. It is much appreciated.***

Regards

Paul

Hi Paul,

Thanks for your reply. Yes the Client checkbox is ticked. But, we are seeing an error logged in the console: "Cannot read property 'open' of null" which does suggest it doesn't recognise the Window object.

James Foot
Kilo Expert

Replace

window.open(url, "_self");

with

g_navigation.openPopup(url);

 

Final code should look like this:

function selectStandardChangeWD(){
	var url = 'sp?id=request_standard_change_webdev&sysparm_domain_restore=false&sysparm_stack=no&ticket_sys=' + g_form.getUniqueValue();
	g_navigation.openPopup(url);
	return false;
}

Thanks James. This worked perfectly. We decided to use g_navigation.open(url) just to keep the page within the same frame.