Merge pull request #1825 from victorsl/BUG-12173
BUG 12173 "Trigger Execution" SOLVED
This commit is contained in:
@@ -1706,10 +1706,13 @@ class wsBase
|
||||
* @param string $userId
|
||||
* @param string $taskId
|
||||
* @param string $variables
|
||||
* @param int $executeTriggers : Optional parameter. The execution all triggers of the task, according to your steps, 1 yes 0 no.
|
||||
* @return $result will return an object
|
||||
*/
|
||||
public function newCase ($processId, $userId, $taskId, $variables)
|
||||
public function newCase($processId, $userId, $taskId, $variables, $executeTriggers = 0)
|
||||
{
|
||||
//$executeTriggers, this parameter is not important, it may be the last parameter in the method
|
||||
|
||||
$g = new G();
|
||||
|
||||
try {
|
||||
@@ -1737,7 +1740,6 @@ class wsBase
|
||||
}
|
||||
|
||||
$oCase = new Cases();
|
||||
$oTask = new Tasks();
|
||||
$startingTasks = $oCase->getStartCases( $userId );
|
||||
array_shift( $startingTasks ); //remove the first row, the header row
|
||||
$founded = '';
|
||||
@@ -1778,6 +1780,7 @@ class wsBase
|
||||
return $result;
|
||||
}
|
||||
|
||||
//Start case
|
||||
$case = $oCase->startCase( $taskId, $userId );
|
||||
|
||||
$_SESSION['APPLICATION'] = $case['APPLICATION'];
|
||||
@@ -1799,6 +1802,22 @@ class wsBase
|
||||
$oldFields['TAS_UID'] = $taskId;
|
||||
$up_case = $oCase->updateCase( $caseId, $oldFields );
|
||||
|
||||
//Execute all triggers of the task, according to your steps
|
||||
if ($executeTriggers == 1) {
|
||||
$task = new Tasks();
|
||||
$arrayStep = $task->getStepsOfTask($taskId);
|
||||
|
||||
foreach ($arrayStep as $step) {
|
||||
$arrayField = $oCase->loadCase($caseId);
|
||||
|
||||
$arrayField["APP_DATA"] = $oCase->executeTriggers($taskId, $step["STEP_TYPE_OBJ"], $step["STEP_UID_OBJ"], "BEFORE", $arrayField["APP_DATA"]);
|
||||
$arrayField["APP_DATA"] = $oCase->executeTriggers($taskId, $step["STEP_TYPE_OBJ"], $step["STEP_UID_OBJ"], "AFTER", $arrayField["APP_DATA"]);
|
||||
|
||||
$arrayField = $oCase->updateCase($caseId, $arrayField);
|
||||
}
|
||||
}
|
||||
|
||||
//Response
|
||||
$result = new wsResponse( 0, G::loadTranslation( 'ID_STARTED_SUCCESSFULLY' ) );
|
||||
$result->caseId = $caseId;
|
||||
$result->caseNumber = $caseNr;
|
||||
|
||||
@@ -396,7 +396,12 @@ class CaseScheduler extends BaseCaseScheduler
|
||||
$paramsRouteLogResult = $paramsLogResultFromPlugin['paramsRouteLogResult'];
|
||||
} else {
|
||||
eprint( " - Creating the new case............." );
|
||||
$result = $client->__SoapCall( 'NewCase', array ($params) );
|
||||
|
||||
$paramsAux = $params;
|
||||
$paramsAux["executeTriggers"] = 1;
|
||||
|
||||
$result = $client->__SoapCall("NewCase", array($paramsAux));
|
||||
|
||||
if ($result->status_code == 0) {
|
||||
eprintln( "OK+ CASE #{$result->caseNumber} was created!", 'green' );
|
||||
|
||||
@@ -499,7 +504,10 @@ class CaseScheduler extends BaseCaseScheduler
|
||||
$paramsLog = array ('PRO_UID' => $processId,'TAS_UID' => $taskId,'SCH_UID' => $sSchedulerUid,'USR_NAME' => $user,'RESULT' => '','EXEC_DATE' => date( 'Y-m-d' ),'EXEC_HOUR' => date( 'H:i:s' ),'WS_CREATE_CASE_STATUS' => '','WS_ROUTE_CASE_STATUS' => ''
|
||||
);
|
||||
|
||||
$result = $client->__SoapCall( 'NewCase', array ($params) );
|
||||
$paramsAux = $params;
|
||||
$paramsAux["executeTriggers"] = 1;
|
||||
|
||||
$result = $client->__SoapCall("NewCase", array($paramsAux));
|
||||
|
||||
eprint( " - Creating the new case............." );
|
||||
if ($result->status_code == 0) {
|
||||
|
||||
@@ -410,6 +410,7 @@
|
||||
<xs:element name="processId" type="xs:string"/>
|
||||
<xs:element name="taskId" type="xs:string"/>
|
||||
<xs:element name="variables" maxOccurs="unbounded" type="xs0:variableListStruct"/>
|
||||
<xs:element name="executeTriggers" minOccurs="0" maxOccurs="unbounded" type="xs:integer"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
@@ -589,7 +589,7 @@ function DerivateCase ($params)
|
||||
$oStd->wsSessionId = $params->sessionId;
|
||||
|
||||
$ws = new wsBase( $oStd );
|
||||
$res = $ws->derivateCase( $user['USR_UID'], $params->caseId, $params->delIndex );
|
||||
$res = $ws->derivateCase($user["USR_UID"], $params->caseId, $params->delIndex, true);
|
||||
|
||||
return $res;
|
||||
}
|
||||
@@ -616,7 +616,7 @@ function RouteCase ($params)
|
||||
$oStd->wsSessionId = $params->sessionId;
|
||||
|
||||
$ws = new wsBase( $oStd );
|
||||
$res = $ws->derivateCase( $user['USR_UID'], $params->caseId, $params->delIndex );
|
||||
$res = $ws->derivateCase($user["USR_UID"], $params->caseId, $params->delIndex, true);
|
||||
|
||||
return $res;
|
||||
|
||||
@@ -765,7 +765,8 @@ function NewCase ($params)
|
||||
$params->variables = $field;
|
||||
|
||||
$ws = new wsBase();
|
||||
$res = $ws->newCase( $params->processId, $userId, $params->taskId, $params->variables );
|
||||
|
||||
$res = $ws->newCase($params->processId, $userId, $params->taskId, $params->variables, (isset($params->executeTriggers))? (int)($params->executeTriggers) : 0);
|
||||
|
||||
// we need to register the case id for a stored session variable. like a normal Session.
|
||||
$oSession->registerGlobal( "APPLICATION", $res->caseId );
|
||||
|
||||
Reference in New Issue
Block a user