Unofficial documentation how to do interesting things and work around problems in ProcessMaker

Moderator: amosbatto

Forum rules: Unofficial documentation for features which have not been tested by Quality Assurance or may change in future versions of ProcessMaker
#794510
Many ProcessMaker functions will change the system variables if they are executed for another case or with another user. For example, if executing PMFDerivateCase() with a case which isn't the current case or with a user who isn't the current logged-in user, then the system variables will be changed, which can cause problems executing the next step in the task or routing to the next task after the trigger finishes. To avoid these problems, it is necessary to call G::sessionVarSave() before executing the ProcessMaker function and then call G::sessionVarRestore() before the trigger ends.

G::sessionVarSave()
G::sessionVarSave() stores the session variables so they can be restored later using G::sessionVarRestore(). It may be necessary to use this function when calling PM Functions for cases which aren't the current case or for users which are the current logged-in user. For example, it is necessary to use this function if wishing to call PMFDerivateCase() for a case which isn't the current case, send an email in another case with PMFSendMessage(), or use PMFGenerateOutputDocument() to generate an Output Document file in another case assigned to a different user.

Definition:
void G::sessionVarSave()

Return Value:
None.

Note: This function saves the following session variables, which correspond to the system variables:
$_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["PROCESS"], $_SESSION["TASK"],
$_SESSION["USER_LOGGED"], $_SESSION["USR_USERNAME"], $_SESSION["STEP_POSITION"]


Example:
Generate an Output Document for a case which is selected in a previous DynaForm.
Code: Select all
if (isset(@@caseId) and !empty(@@caseId)) {
   $g = new G();
   $g->sessionVarSave();
   PMFGenerateOutputDocument(@@outputDocId, @@caseId, @%index, @@userId);
   $g->sessionVarRestore();
}
G::sessionVarRestore()
G::sessionVarRestore() restores the session variables that were previously saved with the G::sessionVarSave() function.

Definition:
void G::sessionVarRestore()

Return Value:
None.

Note: This function restores the following session variables, which correspond to the system variables:
$_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["PROCESS"], $_SESSION["TASK"],
$_SESSION["USER_LOGGED"], $_SESSION["USR_USERNAME"], $_SESSION["STEP_POSITION"]


Example:
Route on all the other open tasks in the current case, except the current task:
Code: Select all
$caseId = @@APPLICATION;
$index = @%INDEX;
$sql = "SELECT * FROM APP_DELEGATION WHERE APP_UID='$caseId' AND 
   DEL_INDEX<>$index AND DEL_THREAD_STATUS='OPEN'";
$aTasks = executeQuery($sql);
$g = new G();
$g->sessionVarSave();
foreach ($aTasks as $aTask) {
   PMFDerivateCase($aTask['APP_UID'], $aTask['DEL_INDEX'], true);  
}   
$g->sessionVarRestore();
Version 3.2.2

Hello, Does it means that Process Marker is leavi[…]

Resolved by making the changes in apache2.conf. Th[…]

Add Days to date

Solved Thank you very much

Hey I m using Process maker 3.2.2 And i want to c[…]