Passing URL parameters through the service catalog

Ryan M
Giga Guru

I am looking to pass additional URL parameters through the service catalog from page to page.

 

As an example.  
https://<instance>.service-now.com/sp?id=sc_category&sys_id=c3d3e02b0a0a0b12005063c7b2fa4f93&myparameters=stuff

The issue arises when you make the next selection in the catalog.   The tiles within the catalog are not built to also include any additional parameters.  When you click on a tile (sc_catagory page -> sc-category widget), $scope.onClick

executes a function that gathers the tile link data and then calls the following:

 

$scope.$emit($scope.options.click_event_name, evt);

 

evt contains the item that was clicked and the link parts but it does not append or include any additional parameters that may have been added to the URL so once the next page loads the parameters are lost.

I'm not sure where to go from here.  In this case the event that is passed ($scope.options.click_event_name) is $sp.cat_item_list.click.   Where is this defined?  Can I change it?

 

1 ACCEPTED SOLUTION

Ryan M
Giga Guru

In the client script for both the sc-categories and sc_category widgets there is a section that builds a list of parameters.  Here you can add any additional parameters that you want to pass along. 

var s = {
     'id': c.data.page || 'sc_category',
     'sys_id': category.sys_id,
     'catalog_id': c.data.catalog_id,
     'spa': 1,

     'new_param': c.data.new_param
};

 

Don't forget to also read the existing parameter into the data object in the server script.

 

data.new_param = $sp.getParameter('new_param');

 

View solution in original post

5 REPLIES 5

Thanks for sharing the solution! We are wanting to go back to oob cart and this will probably help us too as it also uses an on-click action (button) which would need us to be able to do this. Thanks again! 😁