UI Action - Open in new tab

cc11
Tera Contributor

I have a UI action 'Button' and my goal is to open a child form(escalations) in a new tab.

I use the following -

Client = True

Onclick = openInNew()

Script -

function openInNew(){

var parent = new GlideRecord("x_123456_app_case");

g_navigation.openPopup('x_123456_app_escalations.do?sysparm_query_override=case_id=' + parent.sys_id);

}

The problem I am having -

The function works only in the following case,

function openInNew(){

var parent = new GlideRecord("x_123456_app_case");

g_navigation.openPopup('x_123456_app_escalations.do?sysparm_query_override=case_id=' + parent.sys_id);

}

I need to pass the parent sys_id as a URL parameter.

Looking for help,

Regards,

Yogesh

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Yogesh,



Is the parent field on the current form? If yes then replace var parent = new GlideRecord("x_123456_app_case"); with


var parent = g_form.getValue('parent'); and replace g_navigation.openPopup('x_123456_app_escalations.do?sysparm_query_override=case_id=' + parent.sys_id); with g_navigation.openPopup('x_123456_app_escalations.do?sysparm_query_override=case_id=' + parent);



Reference article on how to adjust client and server side code.


https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/


View solution in original post

4 REPLIES 4

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Yogesh,



Is the parent field on the current form? If yes then replace var parent = new GlideRecord("x_123456_app_case"); with


var parent = g_form.getValue('parent'); and replace g_navigation.openPopup('x_123456_app_escalations.do?sysparm_query_override=case_id=' + parent.sys_id); with g_navigation.openPopup('x_123456_app_escalations.do?sysparm_query_override=case_id=' + parent);



Reference article on how to adjust client and server side code.


https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/


Thanks Pradeep, that worked for me with a slight change,



var parent = g_form.getUniqueValue();



Thank you again, appreciated,


Yogesh


I have a similar requirement. is there any way to pass the following parameters into g_navigation.openPopup().

g_navigation.openPopup('testkb?spa=1&query='); // this works

but I need to pass the following parameters in the url: 

var url = "testkb?spa=1&query=" + escape(current.short_description) + ' ' + escape(current.u_test) + "&sysparm_operator=IR_OR_QUERY";

g_navigation.openPopup('url'); //doesnt work

 

Any idea? Thanks in advance 

Try g_navigation.openPopup(url);

'url' is a String.