ViewFlow HelloWorldFlow programmatic trigger of StartActivation not saving process

147 Views Asked by At

I tried to trigger off a new HelloWorldFlow (demo from ViewFlow) Process instance programmatically instead of via CreateProcessView using the following code. However after executing the code, I find that the nothing is saved to the database.


        flow_task = flow.Start()
        flow_task.flow_class = HelloWorldFlow

        act = activation.StartActivation()
        act.initialize(flow_task, None)

        # execute and save
        act.prepare()
        act.done()

When I tried to force a process save by adding act.process.save(), I find that the process data is saved but there are no tasks associated (unlike the process instance created from the UI which has the start task associated)

        # execute and explicit save
        act.prepare()
        act.process.save()
        act.done()      

I tried to trace through the code but there was no error anywhere inside the StartActivation code and hence I cannot find anything wrong. Appreciate any pointers for me to investigate why the code isn't behaving as expected.

1

There are 1 best solutions below

0
kmmbvnr On

To start flow programmatically, you need to usse flow.StartFunction, instead of flow.Start

http://docs.viewflow.io/viewflow_core_node.html#viewflow.nodes.StartFunction