- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2019 04:39 AM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2019 05:42 AM
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;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2019 05:06 AM
Is the Client checkbox ticked on your UI Action?
If not 'window.open' won't be recognized
Regards
Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2019 05:18 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2019 05:42 AM
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;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2019 06:26 AM
Thanks James. This worked perfectly. We decided to use g_navigation.open(url) just to keep the page within the same frame.