To automatically start a process, we need to

$maestro = Maestro::createMaestroObject(1);
 $newprocess_id = $maestro->engine()->newProcess(3);

However here the id 3 is hardcoded. Is there an api / configuration with which the id can be looked up instead of hardcoding in the code?

Comments

_randy’s picture

The 3 in your case is the ID of the flow template.
The only way to get around that is to do a query in the template table to pick off the ID of the flow you wish to start right now.

We will be going down the road of machine names for flows and tasks to help in this exact scenario.

sukr_s’s picture

Thanks for the quick response. I've written a small module to make this possible http://drupal.org/project/maestro_initiator. Would be great if you can add this as a related module in Maestro project

_randy’s picture

@sukr_s: Thanks for the work on your module.
I was/am a little confused on a few things in that module. I think it comes down to terminology.

Templates are what you initiate. When a template is initiated, they become a process. I see the wording of "process" throughout the module and had a hard time understanding what you were trying to do with the code as process means something different than template. At least this is what I think you are intending. Correct me if I'm wrong.

From what I can see, your module needs to have hooks written in Maestro for all workflow templates then; not just modules. Any given project could have many multiple workflow templates.

The only long term issue I see is that this approach is still ID based such that any porting of the workflows would still have to be subject to a transformation from one system to another. The solution is to still have machine names for the templates (and further to that, tasks as well).

sukr_s’s picture

@_randy: yes there may be a terminology confusion. I'm happy to correct where ever needed.

The problem that we are facing is that we are using maestro in a large project that will typically go through dev -> test -> production with multiple people working on it. So it is not possible for us to use templateid (the value used in newprocess() call) to initiate a process as each user will model the template he is working on and ids will clash in the code and will be different in test & production system.

So we need a capability to model the templates in dev systems and map them in test system / production system to events (triggers or points where workflow can be initiated) so that the code is not impacted by the change in template ids.

This mapping approach gives the advantage of versioning templates and switching versions plus if the customer wants to switch off a process initiation for certain events then we just have to remove the mapping and the process won't be initiated and no code change is needed.

The machine name will be a good solution for id clash issue, but is not sufficient as it will not help in switch-off/switch-on the process initiation.

Hope I've been able to throw some clarity.