Catalog Client Script to Redirect to a Catalog Item in SP and UI16

guiguille
Giga Expert

Hey guys,

I received a request to redirect from a catalog item to another one when a checkbox is set as TRUE. We are in Helsinki patch 8, and we are using Service Portal for the users with no roles. This means that the users with roles are using UI16. The solution today is to user a catalog client script, calling the following script include:

var HuluEnvUrl = Class.create();

HuluEnvUrl.prototype = Object.extendsObject(AbstractAjaxProcessor, {

  getUrl: function() {

            var url;

            var myUserObject = gs.getUser();

            if (myUserObject.hasRoles())

                      url = gs.getProperty('glide.servlet.uri') + "com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=<sysID>";

            else

                      url = gs.getProperty('glide.servlet.uri') + "/hulusp?id=sc_cat_item&sys_id=<sysID>";

     

  return url;

  }

});

This is checking if the user has roles or not. This partially works, but it doesn't contemplate if a user with roles found it's way into SP and is navigating over there.

My question is, is there a way to detect if I'm currently in Service Portal? Or there's another better way to do redirects? I don't see my current solution as bullet proof, and I couldn't find any information in the community talking about a scenario like this one.

Any thoughts?

Thanks!

Regards

7 REPLIES 7

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Have you looked at "order guides". There you can have a few "startup questions" and based on the answers item x or item y or both shows for the user etc..



//göran


Hi Goran,



I'm not familiarized with order guides, but what I saw its like a way to group catalog items. We need in this case to redirect from a catalog item to another one. The complete requirement is to have a reference field with several CIs. A checkbox will appear below this variable saying "The CI doesn't appear". When clicked, it should redirect you to another catalog item to request the CI creation. Do you think this could be solved with order guides?



Thanks!


Hi,



I have a very similar requirement. When a check box is checked it opens another catalog item. Were you able to find some way to achieve this?



Thanks,


Debashree


Vladi1
Kilo Guru

I use onChange script for redirect but it does not work on ServicePortal.


function onChange(control, oldValue, newValue, isLoading) {


  if (isLoading || newValue == '') {


  return;


  }


  var request_type = g_form.getValue('v_request_type');


  if (request_type == 'request_type_option')


  window.location.href = 'link to another ritm';


}



reference to:


Re: Redirect to another catalog item