Redirect to a specific portal page from a catalog

Wayne Richmond
Tera Guru

My predecessor created a widget for ordering IT consumables with an accompanying page on the portal. This was accessed via a link in the Categories menu with this adjustment to the SC Categories widget:

 

$scope.categorySelected = function(category) {
            $timeout(function() {
                if(category.sys_id=='55bd758637656200c641886643990ea2'){//order consumables
                    $location.search({id:'it_consumables'});
                }else{
                $location.search('sys_id', category.sys_id);
                $location.search('catalog_id', c.data.catalog_id);
                $location.search('id', c.data.page ||'sc_category');
                }
            });
    };

 

I want to move this option into one of the Categories so it appears as an item like this:

 

find_real_file.png

 

The only way I could see to acheive this was to create a Content Item. However, the only option I could see was to have the item as 'External Content' and have the URL pointing to the page with the widget on (it_consumables). The problem is, it opens in a new window, which is not desired. How can I acheive this but have it open in the current window?

I considered editing the 'SC Category Page' widget to mimic what my predecessor did with the Categories widget. I thought I might be able to edit this part of the Client Script to include an exception for my item, but I'm not sure where to start?

 

var unregister = $rootScope.$on($scope.options.click_event_name, function($event, o) {
		if ("url" in o)
			$location.href = o.url;
		else
			$location.search(o.search);
	});
1 ACCEPTED SOLUTION

Wayne Richmond
Tera Guru

I got this working by cloning the SC Category Page widget and modify the Client Script:

	$scope.onClick = function($event, item) {
		window.GlideWebAnalytics.trackEvent("Service Catalog", "Catalog Browse", "Item Clicked");
		$event.preventDefault();
		var lp = getLinkParts(item);
		if (lp == "?id=it_consumables") {
			$window.open(lp, '_self');
      return;
  } else if (typeof lp == "string") {
      $window.open(lp, '_blank');
      return;
  }

I added an if statement to capture the url returned and open in _self if true, otherwise open in _blank which is ootb

View solution in original post

3 REPLIES 3

suvro
Mega Sage
Mega Sage

Check this out and configure target

https://docs.servicenow.com/en-US/bundle/sandiego-it-asset-management/page/product/service-catalog-management/task/t_AddingContentItemServiceCatalog.html#:~:text=A%20content%20item%20is%20a,instead%20of%20goods%20or%20services.&text=Content%20items%20can%20reference%20knowledge,or%20external%20web%2Dbased%20content.

Thanks. These settings only apply to the platform and not the Service Portal

find_real_file.png

Wayne Richmond
Tera Guru

I got this working by cloning the SC Category Page widget and modify the Client Script:

	$scope.onClick = function($event, item) {
		window.GlideWebAnalytics.trackEvent("Service Catalog", "Catalog Browse", "Item Clicked");
		$event.preventDefault();
		var lp = getLinkParts(item);
		if (lp == "?id=it_consumables") {
			$window.open(lp, '_self');
      return;
  } else if (typeof lp == "string") {
      $window.open(lp, '_blank');
      return;
  }

I added an if statement to capture the url returned and open in _self if true, otherwise open in _blank which is ootb