Monday, November 30, 2015

Add assets to workflow programatically

Within WCS, Workflows are the way to initiate assets from initial creation step to publish step by going through series of steps & condition wherein each step is governed by different group of users with different permissions.

Sometimes when assets were initially created, they may or may not be in workflow. But sudden requirement like assets should be editable by only certain users, workflow can be best solution for it as WCS can restrict users from editing/deleting by checking against Roles.

But even if you define workflow, how to assign workflow to an asset?
Well, after creating workflow, you have to inspect the asset in Contributor UI -> From Top Navigation, click on View -> Status -> Select workflow process and the participants. These are quite a few steps to do assign workflow for many assets, thus, a requirement to have a utility wherein one could assign workflow to many assets at once.

Procedure:
1. Find the condition by which you can filter which assets are required to be in workflow. For e.g. only page assets are required to be in workflow, only content assets of particular type, etc. Once decided, just write a query + condition using Asset API
2. Loop through each assets and while in loop assign asset to workflow as shown:

Disclaimer: Any sample code on this blog is not officially recommended, use at your own risk.

No comments:

Post a Comment

A simple code compare functionality

One of the most important aspect of any development cycle is deployment and while deployment, it is very important to note the changes don...