Questions and discussion about using ProcessMaker: user interface, running cases & functionality
By ervishu83
#795532
Hi,

I have one Parallel task with Value Based Assignment. Suppose I have assigned that "Parallel Task" to 3 (dynamic number of) users. What I observed, who first filled up form in task is available to another user in that parallel task.

I would like to stop this.

The reason is, I need to implement performance review of employee which will be reviewed by co-workers, which is dynamic per employee.
In this parallel task of "performance review", if first co-workers filled up form, this is available to next co-workers. This must not be available to next user.

Is there any way in processmaker this can be handled? I am using ProcessMaker 3.2 enterprise version.

Thanks in advance.
User avatar
By amosbatto
#795543
There are two ways to handle this problem. The first way is to use a variable number of parallel tasks as in this example:
http://wiki.processmaker.com/3.0/Trigge ... llel_Tasks
You will have to define different variables and create different DynaForms for each parallel task. For example, if you can have a maximum of 6 users assigned to the parallel tasks, then you will have to create six different dynaforms with different variables for each parallel task.

The second way to do it is to use the parallel marker in the task and store the values entered in each parallel task into a grid and then delete the value in the variable. Here is an example:
viewtopic.php?f=41&t=710262&p=789936#p789936
By ervishu83
#795549
Thanks for reply.

For my requirement 2nd option [store values in grid and delete/clear variable] seems more suitable.

but I have one concern here that, string, array, etc variable can be clear with assign blank value. but what to do with file variable?
How can I clear file variable after adding to grid, so that variable show clear for next user in parallel?

Right now, there is a trigger placed at "Before Dynaform", which clear all form variable as below:
Code: Select all
@@s3_notes = "";         // this is string variable
@@s3_performance_evaluation_file = "";         // this is file variable
@@s3_performance_evaluation_file_label = "";         // this is file variable label
However, it clear textbox value. but it does not clear file variable. Please refer below screenshot that show. Notes field value is cleared. but File fields value is not cleared by above trigger code.
form.png
form.png (20.02 KiB) Viewed 6795 times

your help is appreciated.
User avatar
By amosbatto
#795564
This is complicated. You have to use AppDocument::remove() in a trigger to mark the file as deleted in the database so it won't be redisplayed by the File control. Then, you will have to use PMFAddInputDocument() to transfer the file to another Input Document and AppDocument::update() to set the file so it can be displayed in a MultipleFile control in the grid. I will prepare an example for you tomorrow to show how it is done.
User avatar
By amosbatto
#795594
When transferring the data entered by the user in the parallel task to a grid, you can use this code:
Code: Select all
//create the feedback grid if it doesn't already exist
if (!isset(@=feedbackGrid) or !is_array(@=feedbackGrid)) {
    @=feedbackGrid = array();
}

//if the user has already entered data, then overwrite the existing row in grid
$rowIndex = false;
for ($i = 1; $i <= count(@=feedbackGrid); $i++) {
   if (@=feedbackGrid[$i]['userId'] == @@USER_LOGGED) {
       $rowIndex = $i;
       break;
   }
}
//if first time the user has entered data, then add a new row to the grid:
if ($rowIndex === false) {
   $rowIndex = count(@=feedbackGrid) + 1;
}

$aUser = userInfo(@@USER_LOGGED);
$fullName = $aUser['firstname'].' '.$aUser['lastname'];
//can't use checkgroups in grids, so convert to a textarea:       
$requiredList = implode("\n", json_decode(@@typesOfWorkRequired_label));

//write feedback data to grid row:
@=feedbackGrid[$rowIndex] = array(
   'userId'               => @@USER_LOGGED,              //hidden
   'fullName'             => $fullName,                  //textbox
   'feedbackDate'         => @@feedbackDate,             //datetime value
   'feedbackDate_label'   => @@feedbackDate_label,       //datatime label
   'canParticipate'       => @=canYouParticipate[0],     //checkbox value, first element in array
   'canParticipate_label' => @@canYouParticipate_label,  //checkbox label    
   'rateDifficulty'       => @@difficultyRating,         //dropdown value
   'rateDifficulty_label' => @@difficultyRating_label,   //dropdown label
   //for checkgroup, convert array into JSON to store in hidden field:
   'requiredForGoalJson'  => json_encode(@=typesOfWorkRequired),
   'requiredForGoal'      => $requiredList,              //checkgroup converted into textarea
   'comments'             => @@yourComments,             //textarea 
   'specFiles'            => @=goalSpecFiles             //multiplefile
);

//For each file in the MultipleFile control, need to change the value in the
//APP_DOCUMENT.APP_DOC_FIELDNAME field from 'goalSpecFiles' to 'feedbackGrid_<ROW-NO>_specFiles'
//See: http://wiki.processmaker.com/3.0/File_control#storage_of_files_in_grids
$oDoc = new AppDocument();

foreach (@=goalSpecFiles as $aFile) {
    $aFileProps = $oDoc->load($aFile['appDocUid'], $aFile['version']);
    $aFileProps['APP_DOC_FIELDNAME'] = "feedbackGrid_{$rowIndex}_specFiles";
    $oDoc->update($aFileProps);
}

//reset variables so empty for the next user:
@@feedbackDate              = null;
@@feedbackDate_label        = null;
@=canYouParticipate         = null;
@@canYouParticipate_label   = null;
@@difficultyRating          = null;
@@difficultyRating_label    = null;
@=typesOfWorkRequired       = null;
@@typesOfWorkRequired_label = null;
@@yourComments              = null;
@@yourComments_label        = null;
@=goalSpecFiles             = null;
Notice the part where changing the value in the APP_DOC_FIELDNAME field in the database, so the MultipleFile can be displayed in the grid. This will also stop the next parallel user from seeing the files of the previous parallel user.

Here is the whole process to study:
(65.5 KiB) Downloaded 434 times
By arash125
#827501
Hi,
What happens if two users submit the form exactly at the same time? In other words, what happens if a user submit exactly while the trigger is saving the variable values for another user? As the variable values will change after a form is submited, may this make a problem ?

Hi Buddy, Although, there are lots of solution yo[…]

🚀 Kaçırmayın! Dinamik kripto endüstris[…]

Are you thinking of joining the exciting world of […]

I started betting on sports at https://ggbet.co.uk[…]