change state restrict users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2022 08:24 AM
Hi can one helpme with the requirment
CHANGE: Restrict Users from Closing Change Records
No one, including the admin role, should be able to close a change. For Change States, "Closed Successful" and "Closed with Defects", only the Change Manager role should be allowed to set these states.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2022 10:17 AM
(function executeRule(current, previous /*null when async*/ ) {
// if (current.state == '3') // add the backend value for closed
// {
// current.setAbortAction(true);
// }
if ((current.state == '3' || current.state == '14') && !gs.getUser().hasRole('change_manager') && gs.getUser().hasRole('admin'))
{
current.setAbortAction(true);
}
})(current, previous);
This is not working for admin, admin is able to access the two options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2022 10:40 AM
Try this, please
if (((current.state == '3' || current.state == '14') && gs.getUser().hasRole('admin')) || ((current.state == '3' || current.state == '14')) && !gs.getUser().hasRole('change_manager') )
{
current.setAbortAction(true);
}
they will still be able to see the options but when they select it and save the record, they should see an error message.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2022 11:20 PM
hi thanks
by the way the following code has worked and thanks so much for your help
function onLoad() {
var flag = g_user.hasRole('change_manager');
if(flag != true || g_user.hasRole('admin'))
{
g_form.removeOption('state', '3');
g_form.removeOption('state', '14');
}
}