UI Actions: How to stay form?

shun6
Giga Sage

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.');
}
1 ACCEPTED SOLUTION

The Machine
Kilo Sage

In your else statement, have you tried action.setRedirectURL(current)?

It should redirect you to the current GlideRecord.

View solution in original post

4 REPLIES 4

The Machine
Kilo Sage

In your else statement, have you tried action.setRedirectURL(current)?

It should redirect you to the current GlideRecord.

Thanks it worked!

Shivam Techlene
Tera Guru

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.

 

Thanks & Regards,
Shivam Jaiswal

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.

 

Thanks & Regards,
Shivam Jaiswal