- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2017 01:35 PM
Hello, In the catalog workflow I am trying to add a "check" (if statement) in our hardware and software workflow in which users in a certain group are pre-approved and skip the approval piece in the workflow. Here is what I have so far:
(I am not a developer so if this code is incorrect please let me know)
answer = preapprovalcheck();
function preapprovalcheck(){
var userCheck;
if(userCheck.isMemberOf('SN-ApprovedEAs')){
answer = true;
} else {
answer = false;
}
}
Here is the workflow:
Solved! Go to Solution.
- Labels:
-
Customer Service Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2017 07:24 PM
Lets add some debugging. Let me know, what you see in system log after running the below script.
answer=preapprovalcheck();
function preapprovalcheck(){
gs.log('++++++++++++++++++current.requested_for is '+current.requested_for);
var grMem = new GlideRecord('sys_user_grmember');
grMem.addQuery('user', current.requested_for);
grMem.addQuery('group.name', 'SN-ApprovedEAs ');
grMem.query();
if(grMem.next()){
return 'yes';
gs.log('++++++++++++++++In Yes++++++++++++++++++++');
} else {
gs.log('++++++++++++++++In No++++++++++++++++++++');
return 'no';
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2017 01:49 PM
Hi MKhan,
I believe you want to cross check that whether the user, who has raised the request is a member of the particular group or not. If so, please find the below script:
answer = preapprovalcheck();
function preapprovalcheck(){
var grMem = new GlideRecord('sys_user_grmember');
grMem.addQuery('user', current.request.requested_for);
grMem.addQuery('group.name', 'SN-ApprovedEAs ');
grMem.query();
if(grMem.next()){
return 'yes';
} else {
return 'no';
}
I hope this helps.Please mark correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2017 04:55 PM
Hi Amlan,
I have tried this solution but it looks like the pre-approval check is entirely skipped and the request goes to the next task after the approval. I have tested this with users in the pre-approved group and users not in the pre-approved group. Both requests automatically get approved. I used the exact script you posted above.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2017 05:42 PM
Try this. Since this is an approval workflow, it will be on the request table.
answer = preapprovalcheck();
function preapprovalcheck(){
var grMem = new GlideRecord('sys_user_grmember');
grMem.addQuery('user', current.requested_for);
grMem.addQuery('group.name', 'SN-ApprovedEAs ');
grMem.query();
if(grMem.next()){
return 'yes';
} else {
return 'no';
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2017 06:15 PM
Thanks Sanjiv, I have tried this but it is still not working. Every time I submit a catalog request from a user who is NOT in the approved group the request still skips the approval. I don't think it is doing the approval check at all and just approving all users.