Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderator: amosbatto

Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By iliusha
#790270
Hi All,

Is there any way to Reasign a case which exceeded Due Date time to another user from Ad-Hoc list?
Thank You.
By mishika
#790275
Hello,

To reassign a case with exceeded due date to another user you can use the following:

If your requirement is to assign an unassigned case to a user from the list of users given for the Self Service Assignment rule, you can refer the following trigger:
Code: Select all
$proid = '95039502258ebffc057e4b0052480462'; // process id
$today = date("Y-m-d H:i:s", strtotime("now"));
$query = "SELECT APP_UID, DEL_DUE_DATE, MAX(DEL_INDEX) FROM LIST_UNASSIGNED WHERE PRO_UID = '$proid' AND DEL_DUE_DATE <= '$today' GROUP BY APP_UID";
$result = executeQuery($query);
if(is_array($result) and count($result)>0){
	foreach($result as $res){
		$caseid = $res['APP_UID'];
		$delindex = $res['MAX(DEL_INDEX)'];
		$designatedUser = '00000000000000000000000000000001'; // id of user from the assigned users list of the task
		$c = new Cases();
  		$c->setCatchUser($caseid, $delindex + 1, $designatedUser);
	}
}
If you have a different requirement, i.e. you need to reassign an already assigned case, you can refer to the below-given trigger.
The following trigger will work for the case which is already has a user assigned but has exceeded the due date:
Code: Select all
$proid = '95039502258ebffc057e4b0052480462'; // process id 
$today = date("Y-m-d H:i:s", strtotime("now"));
$query = "SELECT APP_UID, DEL_TASK_DUE_DATE, MAX(DEL_INDEX), USR_UID FROM APP_DELEGATION WHERE PRO_UID = '$proid' AND DEL_TASK_DUE_DATE <= '$today' GROUP BY APP_UID";
$result = executeQuery($query);
if(is_array($result) and count($result)>0){
	foreach($result as $res){
		$caseid = $res['APP_UID'];
		$delindex = $res['MAX(DEL_INDEX)'];
		$curruser = $res['USR_UID'];
		$designatedUser = '00000000000000000000000000000001'; // id of the new user to be assigned
		$c = new Cases();
  		@@boolean = $c->reassignCase($caseid, $delindex, $curruser, $designatedUser, 'REASSIGN');
	}
}
I hope this fulfills your requirement. I am still working on the ad-hoc lists and will feedback you as and when I get to know anything helpful.

Hope this helps

Best Regards
Mishika
By iliusha
#790276
Hi Mishika,

Thank you for your solution. Works perfectly for me, i used the second case.
Also, i changed the script to select case-s with Open only Status.
Code: Select all
$proid = '95039502258ebffc057e4b0052480462'; // process id 
$today = date("Y-m-d H:i:s", strtotime("now"));
$query = "SELECT APP_UID, DEL_TASK_DUE_DATE, MAX(DEL_INDEX), USR_UID FROM APP_DELEGATION WHERE PRO_UID = '$proid' AND DEL_TASK_DUE_DATE <= '$today' [b]AND DEL_THREAD_STATUS !='Closed'[/b] GROUP BY APP_UID";
$result = executeQuery($query);
if(is_array($result) and count($result)>0){
   foreach($result as $res){
      $caseid = $res['APP_UID'];
      $delindex = $res['MAX(DEL_INDEX)'];
      $curruser = $res['USR_UID'];
      $designatedUser = '00000000000000000000000000000001'; // id of the new user to be assigned
      $c = new Cases();
        @@boolean = $c->reassignCase($caseid, $delindex, $curruser, $designatedUser, 'REASSIGN');
   }
}
It works great but when i'm executing php -f timereventcron.php i'm receiving the following errors:

PHP Warning: Declaration of XmlForm_Field_CheckGroup::renderGrid($values = NULL, $owner = NULL) should be compatible with XmlForm_Field::renderGrid($values = Array, $owner = NULL, $onlyValue = false, $therow = -1) in /opt/gulliver/system/class.xmlform.php on line 4080
Processing workspace: workflow
+------------------------------------------------+
**ID_EXCEPTION_LOG_INTERFAZ**
Problem in workspace: workflow it was omitted.

Finished 1 workspaces processed
Done!


Workspace "workflow" - is newly created without any tasks or events. Also, connection to mysql database is with root account with full privileges.
Can you please help me to solve this issue?
Thank You.
User avatar
By amosbatto
#790281
Your error has nothing to do with the trigger code. I wonder if you are executing the timereventcron.php file using an incompatible version of PHP. Remember that ProcessMaker only works with PHP 5.4 - 5.6. Do you have multiple versions of PHP installed on your server? If so, then you need to specify the full path to a version of PHP which is compatible. For example:
/opt/processmaker-3.1.3.b1-0/php/bin/php -f /opt/processmaker-3.1.3.b1-0/apps/processmaker/htdocs/workflow/engine/bin/timereventcron.php
By iliusha
#790292
Hi,
Yes, i'm using different version of PHP, but i'm not sure that problem is that:

[email protected]:/opt/workflow/engine/bin# /usr/bin/php5 -v
PHP 5.6.30-0+deb8u1 (cli) (built: Feb 8 2017 08:50:21)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

[email protected]:/opt/workflow/engine/bin# /usr/bin/php5 -f timereventcron.php
PHP Warning: Declaration of XmlForm_Field_CheckGroup::renderGrid($values = NULL, $owner = NULL) should be compatible with XmlForm_Field::renderGrid($values = Array, $owner = NULL, $onlyValue = false, $therow = -1) in /opt/gulliver/system/class.xmlform.php on line 4080
WARNING! No server info found!
Processing workspace: workspace
+------------------------------------------------+
PHP Warning: array_pop() expects parameter 1 to be array, boolean given in /opt/gulliver/thirdparty/creole/Creole.php on line 314
**ID_EXCEPTION_LOG_INTERFAZ**
Problem in workspace: workspace it was omitted.

As you have got seen that after every single updat[…]

issue with processmaker 3.2

Hello! The solution to your question is the foll[…]

BPMN project disappeared

Hi Alex! , maybe you forgot to save your process[…]

mcrypt extension is deprecated!

Hello Ehsan! If you did not find the mcrypt ext[…]