- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2024 06:34 AM - edited ‎02-10-2024 06:36 AM
Hi all,
I want to prevent using "reset password" ui action on sys_user if current user is not assigned any groups and show error message like below script.
When user is not assigned any groups and use this ui action, I redirected to list page.
How to stay form?
var sysId = current.sys_id;
var grmember = new GlideRecord('sys_user_grmember');
grmember.addQuery('user', sysId);
grmember.query();
if (grmember.next()) {
action.setRedirectURL('$pwd_reset_serviceDesk.do?sysparm_user=' + current.sys_id);
} else {
gs.addErrorMessage('Thie user is not assigned any groups.');
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2024 09:45 AM
In your else statement, have you tried action.setRedirectURL(current)?
It should redirect you to the current GlideRecord.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2024 09:45 AM
In your else statement, have you tried action.setRedirectURL(current)?
It should redirect you to the current GlideRecord.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2024 04:20 PM
Thanks it worked!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2024 09:58 AM
Hi @shun6 ,
Try updating your script with the script given below:
var sysId = current.sys_id;
var grmember = new GlideRecord('sys_user_grmember');
grmember.addQuery('user', sysId);
grmember.query();
if (grmember.next()) {
action.setRedirectURL('$pwd_reset_serviceDesk.do?sysparm_user=' + current.sys_id);
} else {
action.setRedirectURL(current); //Redirect to current record
gs.addErrorMessage('Thie user is not assigned any groups.');
}
Please mark my response helpful and correct if it resolves your requirement.
Shivam Jaiswal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2024 03:01 AM
Hello @shun6 ,
Did you get a chance to try this one?
Please mark my response as helpful and correct if it helps resolving your requirement.
Shivam Jaiswal