The CreatorCon Call for Content is officially open! Get started here.

Scripting Help- How to open a Catalog Item in a New Window

Su522
Kilo Sage

I have a UI Action that redirects to a Catalog Item and passes a variable (with the help of a Catalog Client Script)

This works fine.

How can I get this UI Action to open the Catalog Item in a New Window?

Currently, it opens the Catalog Item in the same window, which is not wanted because the end user wants to still have that same original record open, in the original window.

 

Here is my UI Action code:

gs.setRedirect('com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=ea3841fc4751351010057cb2a36d438b&sysparm_short_desc=' + short_desc);
 
Help is greatly appreciated appreciated!!!!
5 REPLIES 5

sadif_raja
Tera Guru

@Su522 

Hello,

To get your **UI Action** to open the **Catalog Item** in a new window, you can modify your UI Action script by using JavaScript's `window.open()` method, which opens the URL in a new tab or window, depending on the user's browser settings.

Here’s how you can update your UI Action code:

Updated UI Action Script:
javascript
function openInNewWindow() {
var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=ea3841fc4751351010057cb2a36d438b&sysparm_short_desc=' + short_desc;
window.open(url, '_blank'); // Opens in a new tab/window
}

openInNewWindow();
```

This will ensure the **Catalog Item** opens in a new window, while the original record remains open in the current window.

If this solution helps, I would appreciate it if you could mark it as helpful!

Best regards,
Raja

@sadif_raja This did not work.

I have tried:

function openInNewWindow() {
var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=ea3841fc4751351010057cb2a36d438b&sysparm_short_desc=' + short_desc;
window.open(url, '_blank');
}

openInNewWindow();

 

And I have tried:

function openInNewWindow() {
var session = gs.getSession();
session.putClientData('short_desc', current.short_description);
var short_desc = current.short_description;

var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=ea3841fc4751351010057cb2a36d438b&sysparm_short_desc=' + short_desc;
window.open(url, '_blank');
}

openInNewWindow();

Joe Wong
Tera Guru

Instead of setRedirect, try using the following in your UI Action:

 

var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=ea3841fc4751351010057cb2a36d438b&sysparm_short_desc=' + short_desc)';
window.open(url,'_blank');

 

You might need to give it the whole URL though.  Give it a try and see if this works.

@Joe Wong Thank you but this didnt work. It has parsing errors