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

I want to know where are the audit trail information saved in the MySQL database and I want to know how can I change the value of an approval path by the backend. I only want to know how to change it by backend if you can let me know which is the table it should be really helpful.

I appreciate any help

Regards
#817527
The information about which fields have been changed is stored in the APP_HISTORY.HISTORY_DATA field in the database in a serialized format. To understand the format used by PHP's serialize() function, see Variable Storage.

If you want to change the data in a case in trigger code, you can use PMFSendVariables() to change the variables saved in the case. Then, you can add another row to the APP_HISTORY table with the OBJ_TYPE set to 'DYNAFORM' and an array of the changed variables in the APP_HISTORY.HISTORY_DATA which has been passed through PHP's serialize() function.

Here is some sample trigger code that you can use:
Code: Select all
//change variables in the current case:
$aVars = array(
     'clientName' => "Acme, Inc.",
     'clientAddress' => "653 Stars Bvd\nHollywood, CA 49583",
     'contractAmount' => 8475.99
);
//save case variables to the database in the APPLICATION.APP_DATA field
PMFSendVariables(@@APPLICATION, $aVars); 

//add new row to the APP_HISTORY table so the changes will appear in Information > Case History
$caseId = @@APPLICATION;
//can be set to current delegation index in the case or the delegation index of the task holding the Dynaform:
$delegationIndex = @@INDEX; 
$processId = @@PROCESS;
$taskId = @@TASK;
//set to the ID of the Dynaform which holds the fields associated with the variables:
$dynaformId = '924381abc2234e32324adb3827242710ec124'; 
$objectType = 'DYNAFORM';
//can be set to the user who changed the data:
$userId = @@USER_LOGGED;
$now = date('Y-m-d H:i:s');
$caseStatus = 'DRAFT';  //can be set to 'DRAFT' or 'TO_DO'
$sData = serialize($aVars); 

$sql = "INSERT INTO APP_HISTORY 
   (APP_UID, DEL_INDEX, PRO_UID, TAS_UID, DYN_UID, OBJ_TYPE, USR_UID, APP_STATUS, 
   HISTORY_DATE, HISTORY_DATA) 
   VALUES 
   ('$caseId', $delegationIndex, '$processId', '$taskId', 'dynaformId', '$objectType', '$userId', 
   '$caseStatus', '$now', '$sData')";
@@result = executeQuery($sql);

Note: In order to be able to write directly to your APP_HISTORY table in a trigger, you need to edit your workflow/engine/config/execute-query-blacklist.ini file on the ProcessMaker server and change the line from:
queries="INSERT|UPDATE|REPLACE|DELETE"
To:
queries = "REPLACE|DELETE"

If you want to change an existing record in the APP_HISTORY table, then you need to first use unserialize() to convert the HISTORY_DATA field in an array, then change the value of the changed variables in that array. Then, use serialize() to convert it back into an array and write the changes back to the APP_HISTORY.HISTORY_DATA field.

I have attached a sample process which reads the changes in the APP_HISTORY table for Dynaforms and prints out that list of changes in a grid in the second task. Perhaps the code will help you get started.
Attachments
changedDataInDynaforms.png
changedDataInDynaforms.png (56.42 KiB) Viewed 2622 times
EditDataInDynaformClientInfo.png
EditDataInDynaformClientInfo.png (26.14 KiB) Viewed 2622 times
(40.82 KiB) Downloaded 267 times
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[…]