This commit is contained in:
Paula Quispe
2019-01-16 12:10:25 -04:00
parent 28105f8766
commit 8111550a7d
2 changed files with 12 additions and 8 deletions

View File

@@ -3539,17 +3539,19 @@ class Cases
$varsChanged = $oPMScript->getVarsChanged();
$appDataAfterTrigger = $oPMScript->aFields;
//Get the key and values changed
//Get the key and values changed only if the variable has the prefix
//@see https://wiki.processmaker.com/3.2/Triggers#Typing_rules_for_Case_Variables
$fieldsTrigger = $this->findKeysAndValues($appDataAfterTrigger, $varsChanged);
//We will be load the last appData
if ($oPMScript->executedOn() === $oPMScript::AFTER_ROUTING) {
$appUid = !empty($fieldsCase['APPLICATION']) ? $fieldsCase['APPLICATION'] : '';
if (!empty($appUid)) {
//Update $fieldsCase with the last appData
$fieldsCase = $this->loadCase($appUid)['APP_DATA'];
}
//We will be load the last appData because:
//Other execution can be changed the variables or Plugin or PMFunction
$appUid = !empty($fieldsCase['APPLICATION']) ? $fieldsCase['APPLICATION'] : '';
if (!empty($appUid)) {
//Update $fieldsCase with the last appData
$fieldsCase = $this->loadCase($appUid)['APP_DATA'];
}
//Merge the current appData with variables changed
$fieldsCase = array_merge($fieldsCase, $fieldsTrigger);

View File

@@ -464,6 +464,8 @@ class PMScript
$sScript = "try {\n" . $sScript . "\n} catch (Exception \$oException) {\n " . " \$this->aFields['__ERROR__'] = utf8_encode(\$oException->getMessage());\n}";
$this->executeAndCatchErrors($sScript, $this->sScript);
//We get the affected_fields only if has the prefix
//@see https://wiki.processmaker.com/3.2/Triggers#Typing_rules_for_Case_Variables
$this->setVarsChanged($this->affected_fields);
$this->aFields["__VAR_CHANGED__"] = implode(",", $this->affected_fields);
for ($i = 0; $i < count($this->affected_fields); $i ++) {