Skip to the content
Documentation

How-to trigger a workflow using the Public API: compariso...

No ratings yet

Versions Compared

Old Version 7

changes.mady.by.user Bertrand Dunogier

Saved on May 23, 2013

compared with

New Version 8

changes.mady.by.user Bertrand Dunogier

Saved on May 23, 2013

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note
title Pay attention to the Repository user

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.

Code Block
title Logging a user in
language php
$repository->setCurrentUser( $repository->getUserService()->loadUser( $userId ) );

Of course, this isn't required when using Public API code in controllers, since those will use the currently-logged in user.

 

Data compatibility and workflow collaboration

Content created using the Public API does appear as expected in the dashboard, and the draft can be checked from here. Collaboration options from the backoffice are available, and the object's lifecycle can be managed the way it used to with Exponential 4.x.

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

Comments are read by a moderator before they appear.