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

shloke04
Kilo Patron

Hi,

 

New client-scripts are run in strict mode, with direct DOM access disabled. Access to jQuery, prototype and the window object are likewise disabled. To disable this on a per-script basis, configure UI Action form layout and add the "Isolate script" field. 

find_real_file.png

 

After adding mark that checkbox as true and try your same UI action. IT Should work. check this property as well "glide.script.block.client.globals" which should be marked as false.

 

Hope this help. Please mark the answer as helpful/correct based on impact.

 

Regards,

Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Thank you Shloke, this is handy to know 🙂

Jenny Yeap
Tera Contributor

Just adding this for anyone looking to open the link in a new tab.

Use:

g_navigation.open(url, '_blank');