Hi, yes can already use executeQuery in a trigger, within the PM framework I'm not trying to rewrite the data by hand, but
Code: Select all $caseNo = @@prevcase; //lookup the case number for the case in the Case list
$result = executeQuery("SELECT APP_UID FROM APPLICATION WHERE APP_NUMBER='$caseNo'");
$caseUID = $result[1]['APP_UID'];
G::LoadClass('case');
$oCase = new Cases(); //Create a Cases object
$aCase = $oCase->loadCase($caseUID); //Load case
then tell $aCase to run it's defined trigger on itself
$oCase->executeTrigger('ID_OF_THE_TRIGGER');
amosbatto wrote:You can still do it using a trigger, but you can't execute a case which is already closed, so you have to run a different case which fires a trigger which contains the executeQuery() function.
Your trigger code would be something like this:
Code: Select all//this is the hard part, you need to know the case number or case ID.
//Maybe you can have a DynaForm field named "CaseToModify" where you enter this information:
if (!empty(@@CaseToModify)) {
$caseNo = @@CaseToModify;
$result = executeQuery("select APP_DATA from APPLICATION where APP_NUMBER='$caseNo'");
if ((is_array($result) and count($result) > 0) {
$aCaseData = unserialize($result[1]['APP_DATA']);
$aCaseData['fieldX'] = "some string";
$aCaseData['fieldY'] = 345.99;
$sCaseData = addslashes(serialize($aCaseData));
$result = executeQuery("update APPLICATION set APP_DATA='$sCaseData' where APP_NUMBER='$caseNo'");
//If you have a Report Table, you need to update it as well with executeQuery, like this:
executeQuery("update PMT_MYREPORT set FIELDX='some string', FIELDY=345.99 where APP_NUMBER='$caseNo'");
}
else {
G::SendMessageText("Unable to find case number $caseNo.", "ERROR");
}
}