Link to another Service Portal Page using Service Catalog Content Item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2018 08:27 PM
Hi!
So we have a unique (maybe) and hopefully simple requirement of link a user to a Service Portal page via the Service Catalog. We have built a simple widget that helps us qualify a user's request. Specifically we want to add some meta tags to the Content Item so when a user uses the "Search" they can be shown this page to help them with various items.
I had assumed I could use a Service Catalog Content Item...type = External & target = Within Catalog with a URL pointing to the page we want to direct users.
The only issue is no matter what setting a choose on "target" it always opens a new tab for the user and gets them to the page we defined.
I noticed that the target on the anchor element in the HTML never changes from _blank whether I choose "New Window/Tab" or "Within Catalog" on the Target attribute
I realize this isn't exactly how portal/catalog should work together, but it seems like a simple use case that the Service Catalog should be able to handle (get user to another Service Portal Page without a new window), but the Target attribute seems to make no difference.
Am I missing something here? It seems like ServiceNow gives me the tools to do what I want, but it doesn't work as expected.
Thanks in advance,
Robert
- Labels:
-
Request Management
-
Service Catalog
- 2,613 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2018 01:19 PM
The OOB widget is not able to handle internal links that you do not want to open in a new tab. The only way to specify a specific url is by setting the Content Type to External Content. It should work by using the Target field to set the target of the link, however it sets all External Content to open in a new window.
To make this work, you have to make a copy of the widget "SC Category Page" and modify the Server script. I added comments for where I made a change. It looks for a URL starting with "?id=" as this is what is used for links to other pages on the portal.
Alternatively you could add a new content type to the content item form (ex: Internal Content) and handle that in the server script.
Server script snippet:
var item = {};
item.name = catItemDetails.name;
item.short_description = catItemDetails.short_description;
item.picture = catItemDetails.picture;
item.price = catItemDetails.price;
item.sys_id = catItemDetails.sys_id;
item.hasPrice = catItemDetails.show_price;
item.page = 'sc_cat_item';
item.type = catItemDetails.type;
item.order = catItemDetails.order;
item.sys_class_name = catItemDetails.sys_class_name;
if (item.type == 'order_guide') {
item.page = 'sc_cat_item_guide';
} else if (item.type == 'content_item') {
item.content_type = catItemDetails.content_type;
item.url = catItemDetails.url;
if (item.content_type == 'kb') {
item.kb_article = catItemDetails.kb_article;
item.page = 'kb_article';
item.sys_id = item.kb_article;
} else if (item.content_type == 'external') {
//add code in here to handle links that start with ?id=
if (item.url.indexOf('?id=') == 0) {
//internal portal link
//dont make target a new window (_blank)
} else {
item.target = '_blank';
}
}
}
items.push(item);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2021 02:25 PM
Thanks for the code @stephend'angelo! I have created an idea record to see if ServiceNow will just stop hardcoding the target and pull it from the content item record. Why have a target field if you're not going to use it? Please up vote my idea!