- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2021 06:55 AM
Hello,
I have a before query business rule on incident table.
I want the script to run ONLY when the user sees the incidents on a table on service portal.
The script of the business rule SHOULD NOT run when the user sees incidents on backend.
How can I make this?
Thank you.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2021 02:17 AM
Hi,
Can you add that in the script section?
if that doesn't work then use this
gs.action.getGlideURI().toString().indexOf('csm') > -1
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2021 07:10 AM
Hi,
in the BR condition add this so that it runs only for portal
if(GlideTransaction.get().getRequest().getHeader("referer").indexOf('sp') > -1)
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2021 07:47 AM
Hey Ankur,
should I replace the 'sp' with my portal prefix?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2021 08:17 AM
GlideTransaction.get().getRequest().getHeader("referer") will return the full string of the URL that caused the query to be initiated, so if your portal prefix is /xyz then you would want look for indexOf('xyz') > -1
If you wanted this to be limited to a specific page, you can also include the id parameter:
if(GlideTransaction.get().getRequest().getHeader("referer").indexOf('xyz?id=my_requests') > -1);
I hope this helps!
If this was helpful or correct, please be kind and remember to click appropriately!
Michael Jones - Proud member of the CloudPires team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2021 09:05 PM
that's correct.
use your portal prefix
If my response helped you please mark it correct to close the question so that it benefits future readers as well.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader