Questions and discussion about using ProcessMaker: user interface, running cases & functionality
User avatar
By programerboy
#813455
Hi,

I have a process that I create a sub process in it.
I want use my case notes from main process in sub process and vice versa.
How can I do it?

Thanks
User avatar
By amosbatto
#813479
In your subprocess case, you can add this trigger:
Code: Select all
//get case notes from parent case:
$subcaseId = @@APPLICATION;
$sql = "SELECT AN.* FROM APP_NOTES AS AN WHERE AN.APP_UID=(SELECT SA.APP_PARENT FROM SUB_APPLICATION AS SA WHERE SA.APP_UID='$subcaseId')";
$aNotes = executeQuery($sql);

require_once("classes/model/AppNotes.php");
$oCaseNotes = new AppNotes();

foreach ($aNotes as $aNote) {
   $content = addslashes($aNote['NOTE_CONTENT']);
   $oCaseNotes->postNewNote($subcaseId, $aNote['USR_UID'], $content);
} 
Test it and let me know if it works for you.
By richvle
#825625
Hi Amos, I tested it, and my parent case had 3 notes, however the sub case only got the single most recent note.

The query returns all 3 notes when I ran it, however it only added the single note.
User avatar
By amosbatto
#825627
richvle wrote: Fri Jul 26, 2019 4:00 pm Hi Amos, I tested it, and my parent case had 3 notes, however the sub case only got the single most recent note.

The query returns all 3 notes when I ran it, however it only added the single note.
Creating a new object for each new note worked for me. Do it this way:
Code: Select all
//get case notes from parent case:
$subcaseId = @@APPLICATION;
$sql = "SELECT AN.* FROM APP_NOTES AS AN WHERE AN.APP_UID=(
   SELECT SA.APP_PARENT FROM SUB_APPLICATION AS SA WHERE SA.APP_UID='$subcaseId')";
$aNotes = executeQuery($sql);
@=notes = $aNotes;

require_once("classes/model/AppNotes.php");

foreach ($aNotes as $aNote) {
   $oCaseNotes = new AppNotes();
   $content = addslashes($aNote['NOTE_CONTENT']);
   $oCaseNotes->postNewNote($subcaseId, $aNote['USR_UID'], $content);
} 
User avatar
By amosbatto
#825628
Even better do it this way:
Code: Select all
//if notes haven't yet been copied, then copy them:
if (!isset(@%noteCount)) {
   //get case notes from parent case:
   $subcaseId = @@APPLICATION;
   $sql = "SELECT AN.* FROM APP_NOTES AS AN WHERE 
      AN.APP_UID=(SELECT SA.APP_PARENT FROM SUB_APPLICATION AS SA WHERE SA.APP_UID='$subcaseId')";
   $aNotes = executeQuery($sql);
   @%noteCount = count($aNotes);

   require_once("classes/model/AppNotes.php");

   foreach ($aNotes as $aNote) {
      $oCaseNotes = new AppNotes();
      $content = addslashes($aNote['NOTE_CONTENT']);
      $oCaseNotes->postNewNote($subcaseId, $aNote['USR_UID'], $content);
   }
}
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[…]