I have nodes with workflow field which I need to update using cron from one state to another state. I built a VBO view and tried to use that list as source to which nodes to update. I do not seem to have a way to choose workflow field in Rules at all.
Exported rule below here is not saveable, since "entity-fetched:field-myworkflow" is not exposed at all. Node author (entity-fetched:author) does have fields, but top-level entity does not.
{ "rules_update_wf_state" : {
"LABEL" : "Update Workflow State",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "views_bulk_operations", "rules", "workflow_rules" ],
"ON" : { "cron" : [] },
"IF" : [
{ "views_bulk_operations_condition_result_count" : { "view" : "nodes_for_rules_cron|default", "minimum" : "1" } }
],
"DO" : [
{ "views_bulk_operations_action_load_list" : {
"USING" : { "view" : "nodes_for_rules_cron|default" },
"PROVIDE" : { "entity_list" : { "entity_node_list" : "A list of entity objects" } }
}
},
{ "LOOP" : {
"USING" : { "list" : [ "entity-node-list" ] },
"ITEM" : { "list_item_node" : "Current node" },
"DO" : [
{ "entity_fetch" : {
"USING" : {
"type" : "node",
"id" : [ "list-item-node:nid" ],
"revision_id" : [ "list-item-node:vid" ]
},
"PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
}
},
{ "workflowfield_field_set_state" : {
"node" : [ "entity-fetched" ],
"field" : [ "entity-fetched:field-myworkflow" ],
"workflow_state" : { "value" : { "4" : "4" } },
"workflow_comment" : "Automatically updated state."
}
}
]
}
}
]
}
}
Comments
Comment #1
rpsuI tried to solve this also with custom Rules action (in a custom module), but can't figure out how to simply update workflow field. That would help me go around problem at this point.
Comment #2
johnvI am confused: it seems you need a vbo view to schedule state transitions. That is perfectly possible with the latest version ( there were some problems with this vbo action, but they should be solved.) With that vbo view, you do not need to use an extra Rules thingy.
Please just try to set a scheduled state with VBO. Cron will execute the state change when time comes. If it is not working , it will be fixed.
See also #2189761: How to use Rules support for Workflow Field
Comment #3
rpsuThanks @johnv, but I do not seem to get this working.
My use case is that I need to bulk-update (or programmatically schedule) a state change based on another date field value. I though this would be the easiest thing to do with Views list and loop through items returned by this view but I am apparently wrong.
For example:
I do not find a way to expose workflow field value in Rules to set workflow field value.
Could you please be more spesific how this in your opinion should be done?
Comment #4
rpsuI was probably lost using VBO part, sorry for misleading.
Comment #5
johnvPlease check the following open issues if these are the same, and close this issue as 'duplicate', if that is the case:
- #189572: Add ability to schedule a State change at node creation (not only when editing existing nodes)
- #1825642: Add ability to automatically schedule Transitions after state change
- #486592: How to schedule a following Fixed date transition
The following contains a proposed solution using a 'scheduled Rules Action':
#2217017: Rules action to check workflow field state and to schedule transition
Comment #6
johnvComment #7
johnvComment #8
rpsuFunctionality I am looking for can be achieved also using scheduled workflow transitions, marking this as a duplicate of #2217017: Rules action to check workflow field state and to schedule transition
Comment #9
johnv