Redirect from record (canRead() = false)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2025 06:02 AM
Hi!
I am trying to automatically redirect from a record when no longer readable.
Eg; I have a certain kind of incident that should only be readable by some specific assignment groups.
When an agent reassigns that incident to one of those assignment groups and saves the record, the user stays on the record, which is no longer readable by ACL but the incident is "empty".
This is not a good user experience, and I want to redirect the user back to the previous list.
I have tried setting up a business rule that runs onDisplay, onBefore or onAfter, but it does not redirect the user.
Business rule:
On: Before
Assignment group changes
(function executeRule(current, previous /*null when async*/) {
if(!current.canRead()){
gs.addInfoMessage('You can see this: '+current.canRead());
action.setRedirectURL('incident_list.do');
action.setReturnURL('incident_list.do');
action.setRedirect('incident_list.do');
action.setReturn('incident_list.do');
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2025 06:16 AM
Hi @mathiasjoha ,
I dont think you have access to action.setRedirectURL() in a business rule. Have you tried with gs.setRedirect("your url") instead?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2025 06:28 AM
try this in after update BR
(function executeRule(current, previous /*null when async*/ ) {
if (!current.canRead()) {
gs.setRedirectURL('incident_list.do');
}
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-15-2025 06:47 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-18-2025 04:37 AM
Hi Ankur!
Unfortunately, this did not work either..