Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
User avatar
By groakes
#795915
Hi gurus,

I have a process where a manager is able to assign roles to team members using a grid. The manager adds a row, selects a role from a drop down, then allocates user to that role. This is then used in a routing decision later in the process.

Prior to that routing decision, the manager wants the opprortunity to review the team and change roles as appropriate. I have created a Dynaform which recalls the grid. The manager can add new team members and roles and they get added to the team roster. However, if the manager deletes a row (Team member and role) from the original grid, that role still has a task routed to them in the next step.

I have tried going to the Step where the grid was originally created and removing it there but it still has the same issue.

Is there a way to remove an entry from a grid in a later task?

thanks in advance
Greg
Last edited by groakes on Wed Oct 18, 2017 8:57 pm, edited 1 time in total.
User avatar
By amosbatto
#795918
Let me see if I understand you correctly:
You have a grid variable named MyGrid1 in MyForm1.
Then, you route to tasks based on each row in MyGrid1.
Now you want to remove one of the routed tasks?

Let's say that MyGrid1 has fields with the IDs "userId" and "role", plus a hidden "id" field which is used keep track of which row got deleted.

What you should do is add the id numbers and transfer the contents of MyGrid1 to a second grid variable named MyGrid2. Add this trigger to execute after MyForm1:
Code: Select all
//add ID numbers to each row in the grid:
for ($nRow = 1; $nRow <= count(@=MyGrid1); $nRow++) {
   @=MyGrid1[$nRow]['id'] =  $nRow;
}
//transfer to a second grid:
@=MyGrid2 = @=MyGrid1; 
Then display MyGrid2 in a second DynaForm which the manager can edit.

After that second DynaForm is submitted, then execute a second trigger which compare the contents of @=MyGrid1 to @=MyGrid2. If they aren't the same, then you need to use PMFDerivateCase() route on those tasks, so the user won't work on them.

Your trigger code after the second DynaForm would be something like this:
Code: Select all
foreach (@=MyGrid1 as $aRow1) {
    $foundInGrid2 = false;
   //search for same id in MyGrid2:
   foreach (@=MyGrid2 as $aRow2) {
        if ($aRow1['id'] == $aRow2['id']) {
            $foundInGrid2 = true;
            break;
        }
   }
   
   if ($foundInGrid2 == false) {
       //find the task in the APP_DELEGATION and route it on
       $caseId = @@APPLICATION;
       $userId = $aRow1['userId'];
       //may need to add TAS_UID='$taskId' if searching for a particular task:
       $sql = "SELECT * FROM APP_DELEGATION WHERE APP_UID='$caseId' AND USR_UID='$userId' 
           AND DEL_THREAD_STATUS='OPEN' "; 
       $aTask = executeQuery($sql);
       if (!empty($aTask)) {
           $g = new G();
           $g->sessionVarSave();
           PMFDerivateCase($caseId, $aTask[1]['DEL_INDEX'], false, $userId);
           $g->sessionVarRestore();  
       }
   }  
}
 
Want to create your own meme coin?

In the world of cryptocurrencies, a unique and exc[…]

The market for cryptocurrencies is demonstrating a[…]

What's SAP FICO?

Embarking on a dissertation can be one of the most[…]

Hello. For rental housing, there are software solu[…]