Let's say that your grid is associated with the variable "docsToApprove" and it contains the following fields:
1. MultipleFile with the ID "files", which is Required
2. Dropdown with the ID "approver", which is Required and has the options "Compliance", "Credit" and "Treasury"
Create this trigger to split the "docsToApprove" grid into three separate grids named "docsToApproveCompliance", "docsToApproveCredit" and "docsToApproveTreasury":
Code: Select all@=docsToApproveCompliance = array();
@=docsToApproveCredit = array();
@=docsToApproveTreasury = array();
if (!empty(@=docsToApprove)) {
foreach (@=docsToApprove as $aRow) {
if ($aRow['approver'] == 'Compliance') {
$nextRowNo = count(@=docsToApproveCompliance) + 1;
@=docsToApproveCompliance[ $nextRowNo ] = $aRow;
}
elseif ($aRow['approver'] == 'Credit') {
$nextRowNo = count(@=docsToApproveCredit) + 1;
@=docsToApproveCredit[ $nextRowNo ] = $aRow;
}
elseif ($aRow['approver'] == 'Treasury') {
$nextRowNo = count(@=docsToApproveTreasury) + 1;
@=docsToApproveTreasury[ $nextRowNo ] = $aRow;
}
else {
throw new Exception("Error no Approver selected");
}
}
}
Set this trigger to execute
before assignment in your "Load deal documents..." task.
Then place the "docsToApproveCompliance", "docsToApproveCredit" and "docsToApproveTreasury" grids in forms in your parallel tasks.
In each of these grids, you will have the following fields:
1. MultipleFile with the ID "files", which is Required
2. Dropdown with the ID "approver", whose
display mode is set to "view".
3. Textarea with the ID "comments"
4. Checkbox with the ID "approved", which is Required
Then, create another trigger which will unify the "docsToApproveCompliance", "docsToApproveCredit" and "docsToApproveTreasury" grids in to one grid whose variable is "docsToApprovedUnified":
Code: Select all@=docsToApprovedUnified = array();
$rowCount = 0;
foreach (@=docsToApproveCompliance as $aRow) {
$rowCount++;
@=docsToApprovedUnified[ $rowCount ] = $aRow;
}
foreach (@=docsToApproveCredit as $aRow) {
$rowCount++;
@=docsToApproveUnified[ $rowCount ] = $aRow;
}
foreach (@=docsToApproveTreasury as $aRow) {
$rowCount++;
@=docsToApproveUnified[ $rowCount ] = $aRow;
}
After the parallel tasks and the converging gateway, add a script task and set this script task to fire the above trigger.
If you want the reviewers to have the ability to not approve the document, then don't make the "approved" checkbox required, then add the following code to the end of the above trigger that checks whether any of the documents weren't approved.
Code: Select all@=docsNotApproved = array();
foreach (@=docsToApprovedUnified as $aRow) {
//if document is not approved, then add the filename and approver to the @=docsNotApproved array:
if ($aRow['approved'] == '0') {
@=docsNotApproved[] = $aRow['document'][0]['name'] .' ('. $aRow['approver'];
}
}
Then add an exclusive gateway after the script task with the following conditions in the gateway:
Route back to "Load Deal Documents..." task:
count(@=docsNotApproved) != 0
Route on to the next task in process:
count(@=docsNotApproved) == 0
Then create a Dynaform which contains the "docsToApprovedUnified" grid. Set this Dynaform as the second step in the "Load Deal Documents..." task and add the following condition to the step:
!empty(@=docsNotApproved)
Then, in the same task, add the following condition to the first Dynaform which holds the "docsToApproved" grid:
empty(@=docsNotApproved)