How-to trigger a workflow using the Public API: compariso...
Versions Compared
Old Version 6
changes.mady.by.user Bertrand Dunogier
Saved on May 23, 2013
compared with
New Version 7
changes.mady.by.user Bertrand Dunogier
Saved on May 23, 2013
- Previous Change: Difference between versions 5 and 6
- Next Change: Difference between versions 7 and 8
- View Page History
Key
- This line was added.
- This line was removed.
- Formatting was changed.
...
The code above takes a contentId (object ID), and a version number as the argument, and runs the content/publish operation on it. It then returns true if the operation ended successfully, or false if it was aborted by the workflow engine (or if it failed, but it can be improved).
| Note | |||||||
|---|---|---|---|---|---|---|---|
|
|||||||
| Public API code is always executed as a user, by default anonymous. Since workflows are often user dependent (Approval is), it is important that this code is executed as an editor, or as a user who will trigger the workflow.
Of course, this isn't required when using Public API code in controllers, since those will use the currently-logged in user. |
Data compatibility
Content created using the Public API does appear as expected
Test script
The code below is a working Command script example that demonstrates the workaround. Just drop it in a bundle and update the namespace: https://gist.github.com/bdunogier/e05ed564770fa6a51e51
Comments
Add a comment