- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2024 01:55 AM
I have a Ui action "cancell" in change task table, but for certain task name"PIR" i need to check if the person who is trying to cancel is part of a particular group.
i am trying to do the below code, but it is not working, can someone please help
Solved! Go to Solution.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2024 04:09 AM
Hi @Roshini
Try below code in your ui action script.
gs.GetProperty('property_name') and isMemberOf() cannot be used in client part of the code, so you can write aDisplay BR and store the property value to a g_scratchpad variable. You can then use it in ui action script.
Display BR logic:
g_scratchpad.approverteam= gs.getUser().isMemberOf(gs.getProperty('approverteam'));
Ui Action code:
function moveToCancelled() {
var group_member = g_scratchpad.approverteam; //write a display BR to store if user is part of group or not.
if (g_form.getValue('short_description') == 'PIR' && group_member ) {
g_form.addErrorMessage("you are not allowed to do this action");
return false;
}
g_form.setValue('state', 4);
g_form.setValue('close_code', 'cancelled');
g_form.setMandatory('close_notes', true);
gsftSubmit(null, g_form.getFormElement(), "change_task_to_cancelled");
}
if (typeof window == 'undefined')
setRedirect();
function setRedirect() {
current.update();
action.setRedirectURL(current);
}
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2024 04:09 AM
Hi @Roshini
Try below code in your ui action script.
gs.GetProperty('property_name') and isMemberOf() cannot be used in client part of the code, so you can write aDisplay BR and store the property value to a g_scratchpad variable. You can then use it in ui action script.
Display BR logic:
g_scratchpad.approverteam= gs.getUser().isMemberOf(gs.getProperty('approverteam'));
Ui Action code:
function moveToCancelled() {
var group_member = g_scratchpad.approverteam; //write a display BR to store if user is part of group or not.
if (g_form.getValue('short_description') == 'PIR' && group_member ) {
g_form.addErrorMessage("you are not allowed to do this action");
return false;
}
g_form.setValue('state', 4);
g_form.setValue('close_code', 'cancelled');
g_form.setMandatory('close_notes', true);
gsftSubmit(null, g_form.getFormElement(), "change_task_to_cancelled");
}
if (typeof window == 'undefined')
setRedirect();
function setRedirect() {
current.update();
action.setRedirectURL(current);
}
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP