Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderators: ArturoRobles, ArturoRobles

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.
#794410
In the testing phase, triggers can go wrong. I want to recover case variable state before trigger execution so I don't have to create a new case for every change in trigger's code of a task. To solve the problem, I'm thinking of a simple work around: save all case variables before triggers execution, and set them back at the beginning of the task.

How can I save all case variables at once, and set them back later? Any suggestions?
#794514
First, read this about how PM stores case variables:
http://wiki.processmaker.com/3.0/Trigge ... le_Storage
You also might want to read this:
viewtopic.php?f=47&t=713218&p=794510#p794510

You can create a table which has a backup copy of APP_DATA field. For example, if you have a PM Table named "VAR_BACKUP" with the fields APP_UID and APP_DATA:
BackupVarsPMTable.png
BackupVarsPMTable.png (32.08 KiB) Viewed 1716 times
Then, use this trigger code to store the data:
Code: Select all
$caseId = @@APPLICATION;
//delete any existing records for this case in the backup table:
$sql = "DELETE FROM PMT_VAR_BACKUP WHERE APP_UID='$caseId'";
executeQuery($sql);

$sql = "INSERT INTO PMT_VAR_BACKUP (APP_UID, APP_DATA) VALUES ('$caseId', (SELECT APP_DATA FROM APPLICATION WHERE APP_UID='$caseId'))";
executeQuery($sql);
Then you can use this trigger code to later restore the APP_DATA:
Code: Select all
$caseId = @@APPLICATION;
$sql = "UPDATE APPLICATION SET APP_DATA=(SELECT APP_DATA FROM PMT_VAR_BACKUP WHERE APP_UID='$caseId') WHERE APP_UID='$caseId'";
executeQuery($sql);
Also, if you are using a recent version of PM, then you will need to edit the blacklist file so you can write to the
APPLICATION table. See: http://wiki.processmaker.com/3.0/Consul ... ore_Tables

The 500 Internal Server Error is the general catch[…]

Really very nice blog information for this one and[…]

This is a long, lengthy and cumbersome process. T[…]

Great read for when on the road. The book provides[…]