First, I'd like to say that I'm really excited about this module.

Now, I'm trying to develop something that has a peer review process for academic publishing (author submits paper, goes to editor, editor assigns to three different reviewers, editor gets back results once all three reviewers are done, editor pushed the content on to the layout person — all with conditionals so that they can be rejected). What I want to do, however, is to find a way to circumvent the Maestro UI for the initial author because the instructions to submit an article would be too "complex" for many of the authors to submit if they had to launch a workflow and then create the content. I'd like for the task to be auto-created when a particular content type is submitted.

I know that I can create an "advanced action" that is pre-built called "Launch a Maestro Workflow..." where I select the particular workflow that I want to launch, but I can't find that action for rules; I can find it only for a Maestro "Fire Trigger Task." Is it possible to make that action available to Rules already? If not, what would the process of making it available be?

Comments

_randy’s picture

There's nothing out of the box that does quite what you need.... yet -- however it is 100% doable without rules.

You would use the custom trigger/action to launch a workflow when a piece of content is created. The first task in your workflow would be a batch function that would detect what type of content has just been submitted. If it matches the appropriate content type, you know you can continue.

This requires a bit of coding to be done to create the batch function.

sprice’s picture

Sorry to get back so late to this. Thanks for the quick answer. I'll dive into the coding.

supportPIC’s picture

Hi,

I would be interested too by such a feature. That will perfect this module for my use.

You write to use the trigger module to launch a process when a node is created/edited ? I don't see 'Launch a maestro workflow' in the options in the trigger module. Is there coding to be done here too ?

supportPIC’s picture

Sorry, I found it.

I just had to add the action in the Configuration >> Actions section

Shadlington’s picture

-Deleted-

aron novak’s picture

Assigned: Unassigned » aron novak
Status: Active » Needs review

http://drupal.org/sandbox/aronnovak/1239206

I have a working rules integration of maestro module in my sandbox, not sure if it's a goal to include it to the core maestro, let's discuss here then.
The idea is that you can launch a workflow by acting on any stuff (node, user creation, etc), and you can pass whatever data from any connected entity (node, user, etc) into a variable to the newly created workflow.

grahamtk’s picture

This seems like a natural part of maestro to me.. workflows ought to be able to started when appropriate..
but maybe I don't see the differences or maybe overlaps between maestro module and rules module.

Anyone got tips on where to read up on this?

cheers.

blainelang’s picture

@grahamtk: I recently added rules integration to maestro (dev release) and should have looked at what @aron had done but had forgotten he had posted this a few months ago.

One of the reasons, I was adding the rules integration was to use rules to launch a workflow instance and then create a relation entity record relating the launched workflow to other entity information like the node and user.

Have a read of this blog article and watch the screencast. This should give you some answers to your question.

cthiebault’s picture

I'm using Rules to launch a workflow on node creation (node of specific type).
The workflow starts but it is not attached to the newly created node... is it normal?

Should I use trigger/action to launch my workflow and then check the node type in the first task?

Thanks

blainelang’s picture

The Maestro workflow won't know about the node unless you use rules to set a process variable that you then use in your workflow custom functions. The blog article gives more detail on this. In that demo and blog article, I explain how I was experimenting with the Entity Relations module to create a relationship between the maestro process and the node independently of maestro.

cthiebault’s picture

Thanks for your answer...

I've already watched your video but I'm not sure to fully understand how I should do.

I've created 2 variables (content_type and nid) with Rules before I launch my workflow and I see them when I debug rules_action_launch_workflow function. But the table maestro_project_content is still empty after my workflow is started...

Did I miss something?

blainelang’s picture

Maestro won't inherently know about the node like the maestro content_type task does. You will need to add a batch task with some PHP code to create the record. This is something I want to improve and hence why I was looking at the entity_relations module. This is on my 'would like' list as soon as I get more free time or client project time as I want to improve the integration.

cthiebault’s picture

If it can help other persons launching workflows with Rules, here is the function I used in a Batch Function Task to attach a node to the workflow :

function maestro_attach_node($queue_id, $process_id) {
  global $user;
  
  $maestro = Maestro::createMaestroObject(1);
  
  $content_type = $maestro->engine()->getProcessVariable('content_type', $process_id);
  $nid = $maestro->engine()->getProcessVariable('nid', $process_id);
  $tracking_id = $maestro->engine()->getTrackingId($process_id);
  
  $query = db_select('maestro_queue', 'a');
  $query->fields('a', array('id'));
  $query->condition('a.process_id', $process_id, '=');
  $rec = current($query->execute()->fetchAll());
  $task_id = $rec->id;
    
  $query = db_insert('maestro_project_content');
  $query->fields(array('nid', 'tracking_id', 'task_id', 'instance', 'content_type', 'task_data', 'created_by_uid', 'is_locked_by_uid', 'status'));
  $query->values(array(
    'nid' => $nid,
    'tracking_id' => $tracking_id,
    'task_id' => $task_id,
    'instance' => 1,
    'content_type' => $content_type,
    'task_data' => NULL,
    'created_by_uid' => $user->uid,
    'is_locked_by_uid' => 0,
    'status' => MaestroContentStatusCodes::STATUS_SUBMITTED
    )
  );
  $query->execute();
}

The rule that starts the workflow create 2 variables content_type and nid before launching the workflow.

Nikki Aiuto’s picture

Thank you for the code to insert the nid/content_type into maestro_project_content. I struggled with it for a long time before realizing it must return a boolean value. Maybe you can edit the post to include this for others?

Thanks again.

VictorHugoAus’s picture

Title: Rules Integration » Mailhandler + Feeds Import + Maestro
Issue summary: View changes
Issue tags: +maestro, +mailhandler, +Feeds, +feeds importing, +unpublished

Hello,

I must to say that Maestro is great!

I am trying to create a workflow for content publishing via email as an alternative way to launch a new task.
Actually I am now able to post a node via email, but can't figure out how to automatically launch maestro task and assign unpublished node to another user (reviewer/editor etc).
I suggest that launching workflows with Rules and the function posted above may help to use with a Batch Function Task to attach a node to the workflow.

Could you please explain step by step how to create a Rule and configure Batch Function Task to realize that function?
1) Start ->
2) Import content type ->
3) Review and Assign...

_randy’s picture

@VictorHugoAus

Have look at this video https://www.youtube.com/watch?v=Uu4DnA1Ikqk
Talks about Rules and Maestro - but more importantly, how to launch a flow via Rules.

In essence, all you need to do is to create a Rule that on content creation, launches a Maestro Workflow. Maestro hooks in to Rules to allow you to choose which workflow you'd like to spawn on content creation.

The code posted in #13 could be used in a batch function to write the node ID passed in to a Maestro flow from Rules (as shown in the video) to the appropriate Maestro table so that the node shows up in the details view of a task/workflow under the content section.

So your workflow would be started by Rules. I would probably have a flow like this:

Start -> Batch Function to write node ID to Maestro table -> Approve/Reject Interactive Function task......

The flow is 100% up to you.. but to have the content show up in the details panel, I would put the batch function as the first executable task in the flow.

VictorHugoAus’s picture

Thank you so much for directions.
But how to use the code posted in #13 that could be used in a batch function?
1) Create "Batch function task"
2) Handler: Other > and just copy paste the code into the below field?
I get an AJAX error has occurred. The operation has failed. when trying to save the Batch function task after copy paste the code into the empty filed.
3) Or how can I add or create an option for the Handler to choose, like "maestro_publishNode"?

It is also noticed in #13 that the rule that starts the workflow create 2 variables content_type and nid before launching the workflow. Are those 2 variable created automatically?
Anything to add to Optional tab > Add variable?

_randy’s picture

Read our blog on Maestro topics - this one shows you how to write a batch function amongst other things.

http://www.nextide.ca/maestro_how_to

blainelang’s picture

Status: Needs review » Closed (fixed)
S.Wan’s picture

Hello everyone, I struggled for quite a few days on this issue, how to enter the workflow defined by Maestro automatically once the a content of this content type 'failure report' is saved. I found this issues posted here facing the same problem as mine, and I follow that creating a customized Maestro module and put the code of #13 in, then in the Batch Function Task editor, the function 'Maestro_attach_node' appears.

Then I created a rule for launching workflow, in the EVENT I set 'After saving new content of type Failure Report', in the ACTION I set Launch the workflow that I want.
Then I create a workflow like this 'start--Batch Function Task--assign an engineer...., etc.', in the Batch Function Task, I selected the newly created function 'Maestro_attach_node', and set nothing else.

So, here is the thing, when I created a new content, save it, then go to the Maestro task console, error occurs, it says the $content_type, $nid is empty, so that the database operation is failed. Could you point out where I did wrong, or missed something?

Thank you very much.

_randy’s picture

@S.Wan #20

Did you view the video in comment #16? That plus the blog link show you how to create the needed conditions to send in a node id in to a workflow.

The issue appears to be that you haven't injected the right nid and content type in to the query.