• Sayantan Basu

Automatic Activity In Tridion Workflow

Today I have found the below requirement in the Tridion stack exchange –

Is there any way to rollback published content when workflow step reassigned to Editor?

Though this requirement is not very common but it seems very interesting to me.

I have tried to help that guy by providing the steps only and also started to implement the same in my POC. Once it is done then I feel like it is very good topic for the blog where I can share my code with everyone.

The steps I have followed to fulfill this requirement are –

  1. I have created one simple workflow in Visio. (If you want to know more about how Workflow works in Tridion 2013, then check this blog.)

Workflow Diagram

Workflow Diagram

  1. As you can see in the Workflow Diagram, instead of reassign it directly to Content Creation/Editor Team I have introduced an Automatic activity. Now I can play with the tridion items by implementing my own code using this automatic activity.

  2. Then I write a script which will un-publish the Items and send the task for the next activity. Here I have shown the example for pages only, but you can implement as per your requirement.Here is my code block –

namespace RelianceTridionPublishWorkflow { class UnpublishAndReassign : ExternalActivity {protected override void Execute() { UnPublishInstructionData unPublishInstruction = new UnPublishInstructionData(); unPublishInstruction.ResolveInstruction = new ResolveInstructionData(); //Needed for publishing workflow revision/version unPublishInstruction.ResolveInstruction.IncludeWorkflow = true; ActivityInstanceData activityInstance = ActivityInstance; IList<String> itemsToPublishList = new List<String>(); //Staging publication target URI String[] targets = new[] { “<specify your target type>” }; foreach (WorkItemData wid in activityInstance.WorkItems) { int value = Convert.ToInt32(Enum.Parse(typeof(ItemType), “Page”)); if (wid.Subject.IdRef.EndsWith(value.ToString())) { itemsToPublishList.Add(wid.Subject.IdRef); } } //PublishTransactionData requires reference to System.ServiceModel PublishTransactionData[] publishTransactions = CoreServiceClient.UnPublish(itemsToPublishList.ToArray<String>(), unPublishInstruction, targets, PublishPriority.Normal, null); //Store the publish transaction id so that we can undo if needed! ProcessInstance.Variables.Add(“PublishTransaction”, publishTransactions[0].Id); CoreServiceClient.FinishActivity(ActivityInstance.Id, new ActivityFinishData { Message = “Reassign the activity to Editor” }, null); } } }

4.  Run this code as an external script from that automatic activity.

That’s all! Your solution is ready to serve your requirement. This way you can also implement other functionalities like –

  1. Publish Content

  2. Mail Alert

  3. Auto Approval

Thanks and Keep checking my blogs for future update.

#Tridion2013 #TridionWorkflow #WCM #Workflow

11 views0 comments

Recent Posts

See All

View Workflow ~An Alchemy Plugin for Tridion

View Workflow(An Alchemy Plugin) project was visualized long back by one of our customer when I was working with them as a consultant. In TDS 2018 Hackathon we try to give it a shape. This Plugin is s