logo

NJP

Try it [Portal] Button for Service Catalog and Order guide

Import · May 08, 2021 · article

Hi there,

Created a simple Try it [Portal] Button for catalogs and order guides.

When ever we are working on the catalog or order guide we usually go to the portal page and open the item but by using this button we can open the items from the native UI.

So, the functionality of this button is when we click on it, it will open the catalog or order guide in service portal.

Code:

Name: Try it[Portal]

Table: sc_cat_item

Onclick : onportal()

Condition:

current.active==true;

Code:

function onportal() {
var url = '';
var tablename = g_form.getTableName();
var sysId = g_form.getUniqueValue();
var ins = 'https://dev12345.service-now.com/';  // here change your instance number accordingly
if (tablename == 'sc_cat_item' || tablename == 'sc_cat_item_guide' || tablename == 'sc_cat_item_producer') {
if (tablename == 'sc_cat_item')
url = ins + "sp?id=sc_cat_item&sys_id=" + sysId;       //for Catalog
else if (tablename == 'sc_cat_item_guide')
url = ins + "sp?id=sc_cat_item_guide&sys_id=" + sysId; //for Order guide
else
url = ins + "sp?id=sc_cat_item&sys_id=" + sysId;       //for Record producer
top.window.open(url); // (OR)  g_navigation.openPopup(url) we can use both if we want to open in new or next tab.
top.window.location=url;     //Use this if you want to open in same tab
}
}

Screenshots:

image

image

If this article helps you, Please mark it as helpful or bookmark it!...

Cheers,

Murthy

View original source

https://www.servicenow.com/community/itsm-articles/try-it-portal-button-for-service-catalog-and-order-guide/ta-p/2309093