Advanced group approval script approve when anyone approves for record producer

Magali Legaspi
Tera Contributor

Hello all!

 

I need help with this. I have a record producer, when it gets created, the approval group gets an email notification to ask for approval.

 

What I need to do is when anyone approves, change the state to 'Approved'. 

 

Script:

 

var sys_id = '9fcaab501bf6bc184f11c9d1604bcb84'; //add sys_id of group
var gappr = new GlideRecord('sys_user_grmember');
gappr.addQuery('group', sys_id); // add
gappr.query();
while (gappr.next()) {
{
var grApproval = new GlideRecord('sysapproval_approver');
grApproval.initialize();
grApproval.approver = gappr.user;
grApproval.state = 'requested';
grApproval.sysapproval = current.sys_id;
grApproval.source_table = 'dmn_demand';
grApproval.insert();
}

 

Also I've made this business rule:

 

WHEN TO RUN:

MagaliLegaspi_0-1675774486204.png

 

ACTIONS:

 

MagaliLegaspi_1-1675774515635.png

 

 

This sends the approval notification to all members of the group but needs everyone to approve to change the state to "Approved". I only want one to approve this to move to Approved state.

 

Any help is appreciated!!

1 ACCEPTED SOLUTION

BharathChintala
Mega Sage

@Magali Legaspi create simple workflow or flow trigger condition will which you script to create approvals

 

add group approval activity and select anyone to approve after that set values activity and set state to approved

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala

View solution in original post

1 REPLY 1

BharathChintala
Mega Sage

@Magali Legaspi create simple workflow or flow trigger condition will which you script to create approvals

 

add group approval activity and select anyone to approve after that set values activity and set state to approved

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala