Populate error message in HR Agent workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10 hours ago
Hi Community,
Am trying to limit HR case creation from HR agent workspace(create case). I created a before insert business rule and validating current logged in user. if user belongs to a specific group then hr case should be created otherwise it should throw an error message and stops to insert new case in target table. it works fine in native but error message is not populated on current screen(workspace) when it aborts and shows a pop up immediately. Below is the business rule created. Please can someone assist on this?
script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @Shashic ,
Business rules in Agent Workspace sometimes execute under the user session context rather than admin context, so when your script runs GlideRecord queries (like sys_user_grmember), ACLs can block it.
Instead of using: var userGroupMember = new GlideRecord('sys_user_grmember');
Use: gs.getUser().isMemberOf();
Here's your update script:
if (!gs.getUser().isMemberOf(targetGroup)) {
gs.addErrorMessage('You are not authorized to create a case for the selected service.');
current.setAbortAction(true);
}
If my response helped, please mark it as the accepted solution so others can benefit as well.
Thanks,
MK