Share ideas, ask questions, and get feedback about developing for ProcessMaker
Forum rules: Please post new questions under "Developing processes & programming" for ProcessMaker 2 or 3.
By rundyz
#781276
I have some case data I'd like to manipulate, but the cases are closed.

Think, clean up variables for report table.

I had a brief look, tried to do this with web services, but could only call executeTrigger if I was the case owner- which is fair enough.

I'd like to do this using the PM framework, if anyone has a thought along these lines please share!

Cheers
By rundyz
#782552
Thankyou for this, have to think a bit more laterally,

I was really hoping to use the PM Framework to achieve most of this, and I probably can.
Can you possibly refer me to any further docs, I'm just reading through the 'case' class and can see a method and would be able to lift howto exec a trigger,
but that looks to be designed around running triggers during case steps, will keep looking (might try to find that exectrigger wsdl code)

Cheers
User avatar
By amosbatto
#782586
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");
  }   
}
By rundyz
#782623
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");
  }   
}

ICO software script is a pre-made program for crea[…]

A crypto exchange script is a pre-designed softwar[…]

So I recently bought an addmotor Ebike which of co[…]

A crypto casino clone script is a ready-made softw[…]