How to Auto Approve if the opened by is a member of a group?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2017 08:34 AM
I am looking for a way to auto approve a request if the opened by is a member of a group? Can someone help me how to code it!!!
Thanks.
pK
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2017 08:44 AM
Hi,
it can be done in the workflow, before to launch the approval, use a if action to check if the opened by is member of that group.
if(current.opened_by.isMemberOf('groupname')){
answer = true;
}
else
{
answer = false;
}
Hope it helps!
Regards,
Valentina
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2017 08:50 AM
You can use a run script to do the following:
var usr= new GlideRecord(sys_user_grmember'');
usr.addQuery('user','current.opened_by);
usr.addQuery('group','current.assignment_group);
usr.query();
if(usr.next()){
var app= new GlideRecord(sysapproval_approver'');
app.addQuery('sysapproval','current.sys_id);
app.query();
while(app.next()){
app.state='approved';
app.update();
}}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2017 08:53 AM
Instead if you need to check if the opened by person is member of any group use the following script:
var user = new GlideRecord('sys_user_grmember');
user.addQuery('user', current.opened_by);
user.query();
if(user.hasNext()){
answer = true;
}
else
{
answer = false;
}
Regards,
Valentina
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2017 09:19 AM