How to get mandatory approvals from two people in a workflow and until the two of them approve, it should be 'Requested' and once both of them approve then only it should be 'No longer required'.

utkarsha_s
Kilo Expert

Hi Guys,

Let me know how to get mandatory approvals from two people in a workflow and until the two of them approve, it should be 'Requested' and once both of them approve then only it should be 'No longer required'. If the first person has approved, still it should be in Requested state until one more person approves and then no longer required.

How do I achieve this from a workflow ?

Thanks,

Utkarsha Saxena

1 ACCEPTED SOLUTION

Hi,


Try following code in approval activity of your workflow.



find_real_file.png




Raj


View solution in original post

26 REPLIES 26

Please ignore my code, i read your wrongly. i was in the impression that if approval count is two then move the workflow ahead. Let me check how to get your requirement done.


Not sure about workflow, never tested there but I think you can do it through after update Business Rule on sysapproval_approver table. try if this helps.



(function executeRule(current, previous /*null when async*/) {  


// Add your code here  


var gr = new GlideRecord('sysapproval_approver');  


gr.addQuery('sysapproval', parent.sys_id);


gr.addQuery('approver', gs.getUserID());


gr.query();  


if(gr.getRowCount()>=2)


{


current.state = 'not_required';


}  


})(current, previous);


Hi,



So along with making this Business Rule on approval table on after update, do we also need to make some changes at the workflow level. Like for example, in the workflow, there are group approvals and individual approvals. I want this to happen for the group approval, so do I need to change the approval condition at the workflow and make it to 'everyone to approve' as well ?



Also, how do I link this business rule to the workflow which drives the approvals ?



Thanks,


Utkarsha


I don't think any changes are required from the workflow side but you can have the condition based on script as suggested by rajmasurkar.



You do not need to link the BR with workflow that will be executed automatically when any two approvals get done for that task on sysapproval_approver table.



Please try and check if this helps.


Hi Shishir,



Actually the workflow runs on the change request table for the changes in the change request form and approval table is needed for some approvals that are generated through email notifications.



That is why, I have not made any business rule for this workflow.



I tried doing the code that Raj suggested for the workflow but even after getting two approvals, it didn't stop and become 'No longer required'. How to stop it for that group activity ?



Thanks,


Utkarsha