I want to display Error Message when User is added to a group Manually.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2023 03:43 AM
I created a before insert BR on sys_user_grmember tables, based on few condition we need to restrict addition of the User
I used setabortaction(true) and addErrormessage()
it is not working as the page will redirect to group record
Does anyone the perfect solution for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2023 04:44 AM
Hi @SAI RAJU RAJANA ,
Try below code for restricting creation of users manually
(function executeRule(current, previous /*null when async*/ ) {
if (current.sys_created_by != 'system' || current.sys_created_by != 'admin') { //modify as per your need
gs.addErrorMessage("Users cannot be manually added to any group. Please contact system administrator "); //modify if required
current.setAbortAction(true); // prevent the update from happening
gs.setRedirect(current); // redirected to current page
}
})(current, previous);
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2023 09:46 AM
HI @SAI RAJU RAJANA ,
I trust you are doing great.
Please find the below revised code :
(function executeRule(current, previous /*null when async*/) {
// Replace 'your_condition_here' with the actual condition you want to check.
// Example condition: prevent adding a user to a specific group
// var your_condition_here = (current.group == '<group_sys_id>');
if (your_condition_here) {
// Replace 'Your error message here' with your custom error message.
gs.addErrorMessage("Your error message here");
// Abort the insertion of the record
current.setAbortAction(true);
// Redirect back to the group record
gs.setRedirect(current);
}
})(current, previous);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2023 10:40 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2023 04:04 AM
Hi @SAI RAJU RAJANA,
Try to add current.addErrorMessage("Your error message here"); instead of of gs.addErrorMessage("Your error message here");
you may get error message
If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2025 04:03 AM
Hi,
I've a similar requirement and same issue with me. Was there a solution for this ?