Could you suggest the method that I can use to promote to the Lifecycle state from workflow activity. e.g:. when item moves to “Review” activity on the Workflow, the Lifecycle state changes to “Mgt. Review” state, etc. Can I use Workflow Promotion method. What should I change?
Thanks,
Hi Yelena -
Welcome to the forums. Your best bet to achieve an automatic lifecycle promotion from workflow is to reuse the "Workflow Promote" method. This method is included with the PE solution, but is written to work generically for these purposes. To use it, first attach the method to the Activity Template (the "Review" activity in your example) as an OnActivate server event. Next, you need to create a mapping between the workflow activity and the desired lifecycle state. To do this, create a new Workflow Promotion item and choose the correct activity and state (note that choosing the right activity can be a little tricky if you have many with the same name -- you can rename the activity you want to something like "Choose Me", then change it back after you've created the Workflow Promotion).
We have a simpler way to do all this in the works (no methods required), so stay tuned for updates.
Rob
Just the addendum to the Rob's comment. The onActivate Review activity method (location=Server, type=VB) can be implemented as below.
Dim myInnovator As Innovator = Me.NewInnovator()Dim qry As ItemDim res As Item' Get the Workflow Process idqry = Me.newItem("Workflow Process Activity","get")qry.setProperty("related_id", Me.getId()) 'related item is the activated activityqry.setAttribute("select", "source_id")res = qry.apply()If (res.isError()) Then Return myInnovator.newError("The Workflow Process item cannot be found: " + res.getErrorDetail())' Find the Workflow relationship corresponding to the Workflow Process (and thus to the source item)qry = Me.newItem("Workflow","get")qry.setProperty("related_id", res.getProperty("source_id"))qry.setAttribute("select","source_id,source_type")res = qry.apply()If (res.isError()) Then Return myInnovator.newError("The Workflow relationship cannot be found: " + res.getErrorDetail())' Get the source item (it has to be promoted to the required state)qry = Me.newItem(res.getPropertyAttribute("source_type","keyed_name"),"get")qry.setId(res.getProperty("source_id"))qry.setAttribute("select","id, state")Dim sourceItem As Item = qry.apply()If (sourceItem.isError()) Then Return myInnovator.newError("The source item cannot be found: " + sourceItem.getErrorDetail())' Promote the source itemDim toState As String = "Mgt. Review"If (sourceItem.getProperty("state") <> toState) Then sourceItem.setAction("promoteItem") sourceItem.setProperty("state",toState) res = sourceItem.apply() If (res.isError()) Then Return myInnovator.newError("The promotion to state " + toState + " is failed: " + res.getErrorDetail())End If