I want to use a business rule to check if a user set in the user's reference type column has a speci
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2024 11:57 PM
I want to use a business rule to check if a user set in the user's reference type column has a specific role.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2024 12:03 AM
var user = current.your_reference_field; //
if (user) {
var userGR = new GlideRecord('sys_user');
if (userGR.get(user)) {
if (userGR.hasRole('specific_role')) {
gs.addInfoMessage('The selected user has the required role.');
} else {
gs.addErrorMessage('The selected user does not have the required role.');
current.setAbortAction(true); // Prevent the action (optional)
}
}
}
Kindly mark it correct and helpful if it is applicable.
Thanks,
Raj
Thanks,
Raj