How to open new browser tab from popup modal created by a catalog client script on a catalog item in Service Portal?

patricklatella
Mega Sage

Hi all,

I've got a popup modal that is generated by a catalog client script, everything is working except I can't find the syntax to get the redirect to open in a new browser tab.  Anyone know what I'm missing?  thanks!

Here's the script that opens the modal with the "location.href" that I'm using for now for the redirect...I'm assuming this is not correct.  I've added target="_blank"; 

spModal.open({
title: 'Issue?',
message: 'To report an issue, you need to use a different form in our ESS portal. <p><p>Click the button below to redirect to the correct form.',
buttons: [
{label:'Take me to the correct form', primary: true},
{label:'Stay on this page', cancel: true}
]
}).then(function(){
//populates the "u_practice" field when the cat item opens in ESS portal
location.href='ess/main_content.do?sysparm_content_url=com.glideapp.servicecatalog_cat_item_view.do%3fsysparm_id%3d3f1dd0320a0a0b99000a53f7604a2ef9&sysparm_variables={"u_practice":"34ec3caedbd883006e4d778ebf96198d"}';//this is what I want to open in new tab

target="_blank"; //this does not work
});

1 ACCEPTED SOLUTION

ChrisBurks
Mega Sage

Hi Patrick,

Window may not be available but top is:

var url = "//your.url.here";

...

   top.window.open(url, '_blank');

...

 

Give that a try. It might work.

View solution in original post

9 REPLIES 9

Hi Patrick,

Not sure on that part; I think you will have to try it out in some way

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks Ankur

Hi Patrick,

Can you also mark answer as correct, 👍 helpful if you were able to achieve the requirement and then close the thread.

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

ChrisBurks
Mega Sage

Hi Patrick,

Window may not be available but top is:

var url = "//your.url.here";

...

   top.window.open(url, '_blank');

...

 

Give that a try. It might work.

You are the man Chris!  that's it...thanks!  Hope you've been well.