Approval script output based on the 'answer' sets all group approvals values as Rejected/Approved based on the 'answer' variable in the scriptDescriptionWhen having two groups in Group approval, the first being Approved, and the second being Rejected, the values are not set correctly if using a script in "Condition based on script" for group approval. It instead changes both Group approval results to "Rejected": [code]<pre><code>var appCount = 0;<br/>var rejCount = 0;<br/>var canCount = 0;<br/><br/>for (var id in groups) {<br/> var group = groups[id];<br/><br/> if (group.approved > 0) {<br/> var groupApproval1 = new GlideRecord('sysapproval_group');<br/> groupApproval1.get(id);<br/> groupApproval1.approval = 'approved';<br/> groupApproval1.update();<br/><br/> appCount += 1;<br/> gs.log(current.number + " <Approved>" + groupApproval1.sys_id + " <appCount>" + appCount, "SONIji");<br/> }<br/><br/> if (group.rejected > 0) {<br/> //Approved output : An approval from each group<br/> var groupApproval2 = new GlideRecord('sysapproval_group');<br/> groupApproval2.get(id);<br/> groupApproval2.approval = 'rejected';<br/> groupApproval2.update();<br/><br/> answer = 'rejected';<br/> //rejCount += 1;<br/> gs.log(current.number + " <rejected::rejCount>" + rejCount, "SONIji");<br/> break;<br/> }<br/><br/> if (group.requested == 0) {<br/> canCount += 1;<br/> gs.log(current.number + " <cancelled::canCount>" + canCount, "SONIji");<br/> }<br/><br/>}<br/><br/>gs.log(current.number + " <OUT::counts.approved " + counts.total, "SONIji");<br/><br/><br/>if (counts.total == appCount) {<br/> //Rejected output : An approval from each group<br/> gs.log(current.number + " <OUT::APPROVE>" + appCount, "SONIji");<br/> answer = 'approved';<br/>}<br/><br/>if (counts.total == canCount) {<br/> //Cancelled output : An approval from each group<br/> gs.log(current.number + " <OUT::CANCEL>" + canCount, "SONIji");<br/> answer = 'not_required';<br/>}<br/></code></pre>[/code]Steps to Reproduce 1. Submit 'catalog item : Apple Watch (Workflow: Approval workflow).2. On the RITM, approve the first approval, and Reject the second approval.3. Check the Group approval tab. Observe that both the approvals are set to 'Rejected', even though the fist approval was 'Approved'. The condition based on script is not working. Without script everything works fine.WorkaroundThis is expected behaviour. Ensure that the update to the groups approval records in the script do so with 'setWorkflow(false)'. There are business rules on that table updating the associated user approval records, that will cause the workflow to re-execute each time. Note that in this case, with setWorkflow false, the remaining user approval records for that group will remain in the 'Requested' state until the condition script sets the final state of the approval. Then the activity will set all groups to the final state.Related Problem: PRB1359403