Trigger workflow actions

After you know how to get pages from a specific workflow state you get here the information what you can do with them.

String logonGuid="0904ABF0E43443D2881FE7481339650E";
String sessionKey="490EC675042F4C5A8A6DF1ED63ADD7A6";
String projectGuid="268F46EF5EB74A75824856D3DA1C6597";

CmsClient client = new CmsClient(logonGuid);
Project project = client.getProject(sessionKey, projectGuid);

Page currentPg = project.getPageById(“34009”);
currentPg.reject(“note name”, “reject comment”);

The first method submitToWorkflow()  can be used from an author’s perspective to confirm his changes in Tasks. It will throw a WrongStateException, if the page is not in draft state.

The last both methods are useful from a checkers perspective to return an incorrect page to the author for rework or release the changes. These methods checks for the page state too and will throw a WrongStateException too.

Before triggering one of these methods you should check the page state if you want to prevent throwing this exception.

Because I often had the need to clear the authors list of draft pages completely, because they did not want it anymore, I implemented the method resetDraftState() at Page which works as follows:

  • if the page was created (isInStateSavedAsDraftNew() == true, it will be deleted with delete()
  • if the page was upated (isInStateSavedAsDraftChanged() == true, the change will be skipped with undoChanges()

All you have to do is to call resetDraftState() on all pages you want get out of your Tasks list of draft pages. You can find more details on the determine page state article.

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: