Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Workflow » AUTO transitions
AUTO transitions [message #2481] Mon, 05 April 2010 00:42 Go to next message
ljkbrost is currently offline  ljkbrost
Messages: 59
Registered: April 2006

I have created auto transitions for the sending of emails after the completion of tasks. Everything works great in the 'simple' case. But...

I have a sequence of scripts that get called in the order:

1) add1
2) upd1
3) add1

In the _cm_postInsertRecord() and _cm_postUpdateRecord(), I have placed a call to append2ScriptSequence so that they 'jump' to the next task. Works great!

When I attach a workflow so that an email is sent after each step, the workflow gets hung (no errors) and the sequence works normally. Researching this I have found the the workflow does a similar append2ScriptSequence(). When this happens I get:

    [0] => Array
            [task_id] => step2
            [where] => participant_id='593d-ed0b-7eb1ff0f2110836-2bb949'
            [inserted_by] => step1

    [1] => Array
            [task_id] => send_email
            [where] => participant_id='593d-ed0b-7eb1ff0f2110836-2bb949'


When this executes the 'send_email' function gets lost or only completed at the end of all the tasks. Not a desirable thing as we want emails at the end of each task and not all tasks.

Reviewing the design document on workflows, it makes sense that workflows should always fire before 'business logic nagivation control' as the workflow needs to operate unaware of how the various tasks are actually inmplemented.

If I change the ordering of the logic in 'examineInwardArc(...)' so that all workflow transitions are given priority (at the head of the array), things work as I would expect them to.

I think this is an area that should be altered to make the workflow take priority of the sequence of events and potentially the code should be updated to make use of a similar append2ScriptSequence versus using things hard coded.

This is my modified code in wf_arc.class.inc to make it work.
        if ($arc_data['transition_trigger'] == 'AUTO') {
            // trigger is 'AUTO', so commit current updates and process this workitem now
            $this->errors = $dbworkitem->commit();
            $next['task_id'] = $arc_data['task_id'];
            $next['where']   = $arc_data['context'];

            $current = $_SESSION['script_sequence'];
            $_SESSION['script_sequence']= array();
            $_SESSION['script_sequence'][]= $next;
            foreach($current as $next)
              $_SESSION['script_sequence'][] = $next;

            // terminate current script and activate designated task

        } // if

I think it would also be good to add 'inserted_by' in the sequence array. It would have saved me a bunch of time tracing this and it make sense.


Kyle Brost
Re: AUTO transitions [message #2484 is a reply to message #2481] Mon, 05 April 2010 05:01 Go to previous message
AJM is currently offline  AJM
Messages: 2297
Registered: April 2006
Location: Surrey, UK
Senior Member
Good idea. I've changed this code to use the append2ScriptSequence() function which automatically adds 'inserted_by' (the current task_id) to the array. I have also added a second argument to this function which will cause it to prepend instead of append to the $_SESSION['script_sequence'] array.

Previous Topic: Explicit OR-Split
Next Topic: creating a system that uses workflow
Goto Forum:

Current Time: Mon May 16 11:17:37 EDT 2022

Total time taken to generate the page: 0.01880 seconds