Share ideas, ask questions, and get feedback about developing for ProcessMaker
Forum rules: Please post new questions under "Developing processes & programming" for ProcessMaker 2 or 3.
#15096
Hi,
I want to create multiple subprocess in master process
Here i am explaining in detail , This is an approval process
1] Initially U1 create Request for approval
2] Then its goes to User1=>User2=>User3 by this way
3] Once its reach to User3 , Users3 will Send to Mem1 ,Mem2 ,Mem3 ...n level in Synchronous way
4] All member update his remark and send to next level . Once all Members update his information then it will go to User4
5] User4 can see all members and user remark

I have done up to step 2 , But At Step 3 i am in stuck ,i am using subprocess for Step 3

plz Help me to sort this ASAP
#15113
There is no easy way to create a variable number of subprocess cases. The only way is to manually insert new records in the wf_<WORKSPACE>.APPLICATION table, which have the APP_PARENT field set to the unique ID for the parent case. Not easy and it will take some experimentation on your part to figure out the right values to stick in all the fields.

The other option is to create lots of parallel subprocess tasks and then use a parallel fork by evaluation to only have as many tasks executed as you have members. See: http://forum.processmaker.com/viewtopic.php?f=7&t=3613
#15151
What you can do is use the PMFNewCase() function to create the new case, but then just add a new record in the SUB_APPLICATION table, with the same APP_UID field in the APPLICATION table. I have never tried this, so good luck.
#15186
amosbatto wrote:What you can do is use the PMFNewCase() function to create the new case, but then just add a new record in the SUB_APPLICATION table, with the same APP_UID field in the APPLICATION table. I have never tried this, so good luck.
I have tried this but not sucessful
Following problems are arised
1] sub process are created . and because value based assingn rule its creating two subprocess of one user
its means that if am creating a 3 subprocess , it will creat 4 subprocess
2] once a sub process completed it is not come to main process
3] how i can get all subprocess values in main process
#784846
This is a old topic, I know but I am going to post my findings below.

This script below will insert multiple subprocess cases, as asynchronous (Not Synchronous - Which means variables will not be passed back into the main case)
It loops through a GRID to determine how many sub cases to create. It creates them with PMFNewCase and then updates the correct databases, so stuff does not get out of sync.

*** PROCESSMAKER Support told me that its not do-able and highly suggests not to modify the processmaker database from triggers. But I went and figured it out on my own.
*** Also this may not be complete and may break counts and such, but so far I have not had any issues.

### THIS SCRIPT IS MADE FOR PROCESSMAKER 3.0.1.X (Specifically I am using on 3.0.1.7) ###

*** The webentry users is because I am using the WebEntry feature on the start task and for Actions By Email, you can use a real user in its place.

The Basic steps are
1. PMFNewCase (Create the case)
2. Update Tables "APPLICATION", "LIST_INBOX", "LIST_PARTICIPATED_LAST" and set the APP_STATUS column to "TO_DO".
3. INSERT INTO Table "SUB_APPLICATION"
4. INSERT INTO Table "LIST_MY_INBOX"
5. UPDATE USER CASES COUNT on USERS Table

*** Again this may not be the correct process of doing this, but its working for me... Enjoy
Code: Select all
// Get the Process UID
$getSubProcessUID = "SELECT PRJ_UID FROM BPMN_PROJECT WHERE PRJ_NAME LIKE 'QFL Supervisor SubProcess'";
$results = executeQuery($getSubProcessUID);
$subprocessUID = $results[1]['PRJ_UID'];

// Get the User UID for WebEntry
$getWebEntryUserUID = "SELECT USR_UID FROM USERS WHERE USR_USERNAME LIKE 'webentry'";
$results = executeQuery($getWebEntryUserUID);
$subprocessUserUID = $results[1]['USR_UID'];

// Get the Task UID of the first task on the subprocess
$getSubProcessFirstTaskUID = "SELECT TAS_UID FROM TASK WHERE PRO_UID = '$subprocessUID' AND TAS_START='TRUE'";
$results = executeQuery($getSubProcessFirstTaskUID);
$subprocessFirstTaskUID = $results[1]['TAS_UID'];

// TODO CHANGE subSupervisorEmail
$aFields = array(
  'deleteMeLater' => 'Yay it worked!',
  'subSupervisorEmail' => 'EMAILHERE'
);
// Serialize object because processmaker is lame
// This serilized object needs to be inserted into the SUB_APPLICATION table.
$aFieldsSerialized = serialize($aFields);
$callcenterArray = array('fpi','ost','rsc','techsupport');

if (@@FeedbackDepartment == 'people') {

  foreach(@@AssociatedEmployeeGrid as $row) {

    if (!in_array($row['empChannel'], $callcenterArray)) {
      // Create Case for Row
      $caseUIDReturn = PMFNewCase($subprocessUID, $subprocessUserUID, $subprocessFirstTaskUID, $aFields);

      // PMFNEWCASE RETURNS 0 ON ERROR
      if ($caseUIDReturn) {

        $thisAppID = @@APPLICATION;
        // Move from draft, to inbox!
        executeQuery("UPDATE APPLICATION SET APP_STATUS='TO_DO', APP_PARENT='$thisAppID' WHERE APP_UID='$caseUIDReturn'");

        $currentDateTime = date("Y-m-d H:i:s");
        // Insert into the SUB_APPLICATION TABLE
        executeQuery("INSERT INTO SUB_APPLICATION (
          APP_UID, APP_PARENT, DEL_INDEX_PARENT,
          DEL_THREAD_PARENT, SA_STATUS, SA_VALUES_OUT,
          SA_INIT_DATE, SA_FINISH_DATE
        ) VALUES (
          '$caseUIDReturn', '$thisAppID', '4',
          '1', 'FINISHED', '$aFieldsSerialized',
          '$currentDateTime', '$currentDateTime')");

        // UPDATE LIST_INBOX COLUMN APP_STATUS
        executeQuery("UPDATE LIST_INBOX SET APP_STATUS='TO_DO' WHERE APP_UID='$caseUIDReturn'");

        // No Update to LIST_PARTICIPATED_HISTORY

        // UPDATE LIST_PARTICIPATED_LAST COLUMN APP_STATUS
        executeQuery("UPDATE LIST_PARTICIPATED_LAST SET APP_STATUS='TO_DO' WHERE APP_UID='$caseUIDReturn'");

        // NO UPDATE APP_CACHE_VIEW

        // INSERT INTO LIST_MY_INBOX
        //// First get info from list inbox
        $listInboxReturn = executeQuery("SELECT * FROM LIST_INBOX WHERE APP_UID='$caseUIDReturn'");
        //// Now lets do the insert
        executeQuery("
          INSERT INTO LIST_MY_INBOX
          (APP_UID, USR_UID, TAS_UID, PRO_UID, APP_NUMBER,
          APP_TITLE, APP_PRO_TITLE, APP_TAS_TITLE, APP_CREATE_DATE, APP_UPDATE_DATE,
          APP_STATUS, DEL_INDEX, DEL_PREVIOUS_USR_UID, DEL_PREVIOUS_USR_USERNAME, DEL_PREVIOUS_USR_FIRSTNAME,
          DEL_PREVIOUS_USR_LASTNAME, DEL_CURRENT_USR_UID, DEL_CURRENT_USR_USERNAME, DEL_CURRENT_USR_FIRSTNAME,
          DEL_CURRENT_USR_LASTNAME, DEL_DELEGATE_DATE, DEL_INIT_DATE, DEL_DUE_DATE, DEL_PRIORITY)
          VALUES
          ('$caseUIDReturn', '$subprocessUserUID', '$subprocessFirstTaskUID', '{$listInboxReturn[1]['PRO_UID']}',
           '{$listInboxReturn[1]['APP_NUMBER']}', '{$listInboxReturn[1]['APP_TITLE']}', '{$listInboxReturn[1]['APP_PRO_TITLE']}',
           '{$listInboxReturn[1]['APP_TAS_TITLE']}', '$currentDateTime', '{$listInboxReturn[1]['APP_UPDATE_DATE']}',
           'TO_DO', '{$listInboxReturn[1]['DEL_INDEX']}', '{$listInboxReturn[1]['DEL_PREVIOUS_USR_UID']}', '{$listInboxReturn[1]['DEL_PREVIOUS_USR_USERNAME']}',
           '{$listInboxReturn[1]['DEL_PREVIOUS_USR_FIRSTNAME']}', '{$listInboxReturn[1]['DEL_PREVIOUS_USR_LASTNAME']}', '$subprocessUserUID',
           'webentry', 'WebEntry', 'WebEntry',
           '{$listInboxReturn[1]['DEL_DELEGATE_DATE']}', '{$listInboxReturn[1]['DEL_INIT_DATE']}', '{$listInboxReturn[1]['DEL_DUE_DATE']}',
           '{$listInboxReturn[1]['DEL_PRIORITY']}')
        ");

        // Need to update User Cases Counts...
        //// Lets first select the current counts out of the DB
        $userTableCounts = executeQuery("SELECT USR_TOTAL_INBOX, USR_TOTAL_DRAFT FROM USERS WHERE USR_UID='$subprocessUserUID'");
        //// Now Lets update them
        $newUserInboxCount = $userTableCounts[1]['USR_TOTAL_INBOX'] + 1;
        $newUserDraftCount = $userTableCounts[1]['USR_TOTAL_DRAFT'] - 1;
        executeQuery("UPDATE USERS SET USR_TOTAL_INBOX = '$newUserInboxCount', USR_TOTAL_DRAFT='$newUserDraftCount' WHERE USR_UID='$subprocessUserUID'");

      } else {
        @@CASE_NOT_CREATED += 'Case Not Created for ' . $row['empName'] . '. -|- ';
      }

    }

  }

}
Designer not loading...

Okay after many, many, MANY hours.... I found […]

The Drip casino clone script enables entrepreneurs[…]

Create a cutting-edge crypto sports betting platfo[…]

Betdaq Clone Script is a ready-to-launch solution […]