Process definition is not triggered with an after_save logic hook

Hi All,

I need help. A process definition is not triggered in Cases module with an after_save logic hook . Process Def of updating the status field on initial save for new records doesnt trigger when a custom field is part of the logic hook. Is it the $bean->save() interferring the Process Def to trigger? Anyone can give ensights about this?

Thanks,

Longki

  • Hi Longki,

    A few questions: If you disable the logic hook, does the process definition fire correctly? If so, what are you doing in the logic hook? Can you provide a sample of the code? Let me know if you have any questions!

    -Alan

  • Hi Sir Alan,

    Thanks for the reply, yes disabling the logic hooks triggers the Process Def. Here is my logic hook.

         function incrementSeries($bean, $event, $arguments) {

               global $log, $db;

               if(empty($bean->series_id_c)){

                    if (!isset($bean->ignore_update_c) || $bean->ignore_update_c === false){

                        $bean->retrieve($bean->id);

                        $query = "SELECT series_id_c FROM cases_cstm group by series_id_c desc limit 1";

                        $results = $db->query($query);

                        while($row = $db->fetchByAssoc($results)){

                             $series_id_c = $row['series_id_c'];

                             $last_series_year = substr($series_id_c, 4, 2);

                             $last_series_month = substr($series_id_c, 6, 2);

                             $current_year = date('Y');

                             $current_month = date('m');

                             $last_series_string = substr($series_id_c, 8, 8);

                             $last_series_series = intval(strval($last_series_string));

                             if(!empty($results)) {

                                 $series_id_c = $last_series_series + 1;

                                 $series_id_c = str_pad($series_id_c, 8, '0', STR_PAD_LEFT);

                                 $bean->ignore_update_c = true;

                                 $bean->series_id_c = substr($current_year,2,2) . $current_month .$series_id_c;

                                 $bean->save();

                             }

                        }

                    }

            } else {

                $bean->series_id_c = "";

                $bean->save();

            }

        }

    Regards,

    Longki

  • This is old thread but don't see anyone answered.

    I got the same problem: $bean->save() in after_save logic hook prevented running process definition that has 'changes' condition in start event.

    Here is solution:

    // when $bean is saved within after_save logic hook:
    $dataChanges = $bean->dataChanges;
    $bean->save();
    $bean->dataChanges = $dataChanges;