UI action to open in new window/Tab

Prashant Kumar6
Giga Guru

Hello Experts, 

 

I have created a UI action on story form (rm_story) to create test case (tm_test_case), which is working fine . Now I want to open that in new Tab of the browser , for that I used below code and it is not working . When I used Log it is showing "com.glide.script.RhinoEcmaError: "window" is not defined." 
Note : Isolated script : false . Can anyone please help here?

create_test();
 
function create_test(){
var url;
var TMTC1 = '';
var TMTC = new GlideRecord('tm_test_case');
 TMTC.initialize();
 TMTC.u_type = current.u_test_case_type;
  TMTC1 = TMTC.insert();
 
url = '/tm_test_case.do?sys_id' + TMTC1;
gs.log("Prashant1" + url);
window.open(url,'_blank');
}
2 ACCEPTED SOLUTIONS

Samaksh Wani
Giga Sage

Hello @Prashant Kumar6 

 

try this once :-

 

 

 

g_navigation.open(url);

 

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Samaksh

View solution in original post

praneeth7
Tera Guru

Hello @Prashant Kumar6 

 

This link might help you on this How to Open an URL in New Window from UI Action? 

 

Please mark Helpful if you find this useful. 

Thank you

Praneeth 

View solution in original post

10 REPLIES 10

Sagar Pagar
Tera Patron

Hi @Prashant Kumar6,

 

Try by updating as: gs.setRedirect(url, '_blank'); instead of window.open(url,'_blank');

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar

The world works with ServiceNow

Hi @Sagar Pagar 

I tried that and it is still not working . 
url = '/tm_test_case.do?sys_id' + TMTC1;
gs.log("Prashant1" + url);
//action.setRedirectURL(url);
gs.setRedirect(url, '_blank');

 

Getting logs with correct sys id, however it is not opening in a new tab. Any idea?

 

Hi @Prashant Kumar6,

 

It should work for you. Make sure that you are creating the correct url.

 

Can you try this and let me know. Is it working?

 

url = '/tm_test_case.do?sys_id' + TMTC1;
gs.log("Prashant1" + url);
//action.setRedirectURL(url);
gs.setRedirect(url);

 

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar

The world works with ServiceNow

Hi @Sagar Pagar  , 

Tried with 

url = '/tm_test_case.do?sys_id' + TMTC1;
gs.log("Prashant1" + url);
//action.setRedirectURL(url);
gs.setRedirect(url);

This is opening the record in the same tab , My requirement  was to open that a new tab not on the same tab .