
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2019 08:11 AM
Hi all,
I have a workflow scratchpad variable within an approval on sc_req_item .... and need to remove a potential group approver in case he/she is equal to the requested_by to avoid approving own requests.
Coud someone please help out here? The scratchpad might contain more than one approval group and I need to keep the group approval. Just pushing all approval users to the answer would not be sufficient.
Best would even be that the user remains part of the approval group but his/her approval will automatically changed to "not required anymore".
Thnank you!!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2019 12:40 PM
OK.
More easy with a Business Rule.
Table: sysapproval_approver
before / Insert
condition:
sysapproval.openey_bySAMEapprover^stateCHANGESTOrequested
Scipt:
current.state = 'not_required';
current.comments = ''approval canceled because ....";
Just to make sure, that in case only one approver the whole approval might be approved if set to not required anymore ...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2019 10:45 AM
Zod,
In the below example, your 'group approver' is my 'approver' so just substitute these values:
answer = [];
//'current' object is RITM record for this code
var requester = current.request.opened_by;
//grabing user input - you may be getting your approver a different way
var approver = current.variables.ITRP_OG_Approv;
var approvalGroup = workflow.scratchpad.my_approval_group;
if (approver != requester) {
//if they aren't the same, send approvals to all members
answer.push(approvalGroup);
} else {
//else, add each member to answer array excluding the requester
var gr= new GlideRecord('sys_user_grmember');
gr.addQuery('group', approvalGroup);
gr.addQuery('user','!=', requestor);
gr.query();
while(gr.next()){
answer.push(gr.getValue('user'));
}
I tested this code (minus the last 'else' statement) with a single approver activity ('Approval - User'). If the approver was the same as the requestor, it skipped the Approval activity and continued with the workflow. It should work the same with a group.
Hope this helped!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2019 02:07 AM
... thank you.
But this looks for me like this would push relevant approvers (separat users) to the answer.
But I would nee the groups (that potentially should remove the requestor in case part of the group.
So again.
I have workflow.scratchpad_appval_groups ( is [groupA_sys, groupB_sys]).
Requestor is userA.
If userA is part of groupA the answer shoud contain [groupA_sys, groupB_sys] but userA should be removed from this group for the purpose of this approval.
So maybe the solution is to be fixed somewhere else instead. I.e. a Business Rule saying in case I get a apprval item where I am the requestor - set approval to not required anymore ...
Any idea?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2019 12:40 PM
OK.
More easy with a Business Rule.
Table: sysapproval_approver
before / Insert
condition:
sysapproval.openey_bySAMEapprover^stateCHANGESTOrequested
Scipt:
current.state = 'not_required';
current.comments = ''approval canceled because ....";
Just to make sure, that in case only one approver the whole approval might be approved if set to not required anymore ...