How to Trigger a Business rule only for a Workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 04:24 PM
I would like to know how I could trigger aa Business rule only for a specific workspace
OR
Is there a way to see if a record is created through workspace ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 05:04 PM
Hi,
You can build a custom logic. I can suggest two workarounds-
1. Create a custom field suppose "UI Type" and write a onLoad Client script and check the view if it is "workspace" populate the field UI Type with an appropriate value say "Workspace".
2. Get the URL in the business rule and parse that because the URL from workspace is different (looks like: api/now/ui/ui_action/f4deef100b701300099a83eb37673a4d?api=api&sysparm_sys_id=ed92e8d173d023002728660c4cf6a7bc&sysparm_table=incident)
You can get the URL with the server side code: gs.action.getGlideURI()
If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.
Regards,
Saurabh
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 06:32 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 11:46 PM
Hi,
Please refer below script to parse the URL
var tbl=gs.action.getGlideURI().getMap().get('sysparm_table');
var url=gs.action.getGlideURI().toString();
if(url.indexOf('api/now/ui')>=0 && tbl=='incident')
gs.addInfoMessage("From Workspace");
else
gs.addInfoMessage("Not From Work Space");
If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.
Regards,
Saurabh
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 07:25 PM
Hi,
get URL and check if it's workspace or not
to get parameter from url use this
var myValue = gs.action.getGlideURI().getMap().get('URL Parameter Name');
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader