processmaker

roll back a case to previous step


in process maker I assign some tasks usedStart Custom Task action to some users,

I want to know that is there any way to roll back to previous tasks in such a workflow,

for example if one of users (user1) reject task by mistake and workflow create another task

for next user (user2), is it possible to roll back workflow to previous step and assign task

to user1 again?

I'll be appreciated if anyone could help me.


Solution

  • should delete record from end list of sub_application and app_delegation until record required

    with this code i can restore case from anywhere to anywhere

    foreach($GLOBALS['gridHistory'] as $cuurentTask)
    {
            $cuurentTask["PRO_UID"] =$dbHandle->Convertnumber2english(trim($cuurentTask["PRO_UID"]));
            $cuurentTask["TAS_UID"] =$dbHandle->Convertnumber2english(trim($cuurentTask["TAS_UID"]));
            $cuurentTask["DEL_INDEX"]=$dbHandle->Convertnumber2english(trim($cuurentTask["DEL_INDEX"]));
    
            if($cuurentTask["PRO_UID"]!==$to_PRO_UID || $cuurentTask["TAS_UID"]!==$to_TAS_UID || $cuurentTask["DEL_INDEX"]!==$to_DEL_INDEX)
            { 
                $task_type=task_type($cuurentTask["TAS_UID"],$cuurentTask["PRO_UID"]);
    
                $inPath=checkForExistInPath($to_APP_UID,$cuurentTask["APP_UID"],$to_DEL_INDEX,$cuurentTask["DEL_INDEX"]);
    
                if($task_type=="NORMAL" && $inPath )
                {       
                        if(rollbackAppDelegate($cuurentTask["APP_UID"],$cuurentTask["DEL_INDEX"])!=1)
                            die('خطا در بازگرداندن کار نرمال '.$cuurentTask["APP_UID"]);
                }
                else if($task_type=="SUBPROCESS" && $inPath)
                {
                    $sub_application=$baseClass->query("select APP_UID from sub_application where app_parent='".$cuurentTask["APP_UID"]."' and DEL_INDEX_PARENT='".$cuurentTask["DEL_INDEX"]."'");
                    if(deleteSubProcess($sub_application[0]["APP_UID"])!=1)
                        die('خطا در حذف زیر فرآیند'.$sub_application[0]["APP_UID"]);
                    if(rollbackAppDelegate($cuurentTask["APP_UID"],$cuurentTask["DEL_INDEX"])!=1)
                        die('خطا در بازگرداندن کار موازی'.$cuurentTask["APP_UID"]);
                }
                else
                    echo 'امکان انتقال وجود ندارد.';
            }
            else
            {
                if($APP_CUR_USER=$baseClass->query("select USR_UID from app_delegation where app_delegation.APP_UID='{$cuurentTask['APP_UID']}' order by DEL_INDEX desc LIMIT 1"))
                    if($baseClass->query("update app_delegation set DEL_THREAD_STATUS='OPEN' , DEL_FINISH_DATE=null where  app_delegation.APP_UID='{$cuurentTask['APP_UID']}' and app_delegation.DEL_INDEX='{$cuurentTask["DEL_INDEX"]}';"))
                        if($baseClass->query("update application set APP_STATUS='TO_DO' , APP_FINISH_DATE=null,APP_CUR_USER='{$APP_CUR_USER[0]["USR_UID"]}' where  application.APP_UID='{$cuurentTask['APP_UID']}';"))
                        {
                            echo 'true';
                            break;
                        }
                        else
                            echo 'false';
            }
    }