- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2018 07:37 AM
I have a global business rule that should only run if the user isn't on a certain page (record producer) within the Service Portal. The old function used on our CMS doesn't get enough information (gs.action.getGlideURI().getMap().toString();). How can I get the information I need?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2018 10:16 AM
Found the answer from HI! Add below to your business rule to get the URL of the current page
var referer = GlideTransaction.get().getRequest().getHeader("referer");
gs.log("BR: referer = " + referer+ ".");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2018 11:23 AM
Your record producer should normally generate the following URL: https://<instance_name>.service-now.com/sp?id=sc_cat_item&sys_id=6370e4a27f000001566a807122777e84
So what happens if you try the following code in your global business rule?
if (gs.action.getGlideURI().toString().indexOf('/<suffix of your service portal>?id=sc_cat_item&sys_id=<SYS ID of your record producer>')) {
...business logic to apply...
}
Hope this helps you forward!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2018 11:26 AM
Sorry - my BR is not on the Global table but on a CMDB table -- it's in the global application. Would this still work? Or do I need to do something additional?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2018 12:25 PM
So it's a before query business rule on the application table being consulted by the application list variable of the record producer 🙂
Yes, I would try it anyway in the BR on your CMDB table. First check if you get some logging statement in your System Log:
if (gs.action.getGlideURI().toString().indexOf('/<suffix of your service portal>?id=sc_cat_item&sys_id=<SYS ID of your record producer>')) {
gs.log('REACHED THE RECORD PRODUCER');
}
In case it works...you may relace the log statement by your query criteria.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2018 01:51 PM
That returns true regardless of the catalog item/record producer When I log this: gs.action.getGlideURI().toString().indexOf(), I get this: angular.do?sysparm_type=sp_ref_list_data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2018 01:54 PM
Mmmmmmm...was already afraid it wouldn't work as the Service Portal has its own implementation. Isn't it an option to define a reference qualifier for the variable displaying the application list?