I want to rollback the published content in workflow process when the approver reassign workflow to Editor. is there any default way to do that in tridion with event listener?.
if yes, is this the only way i can do ?.
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI want to rollback the published content in workflow process when the approver reassign workflow to Editor. is there any default way to do that in tridion with event listener?.
if yes, is this the only way i can do ?.
As Alvin suggested, I also think automatic activity is the best way to fulfill your requirement -
When your approver reject the item instead of reassign it to editor, assign it to a automatic activity.Then write a script which will un publish your item first and then send your activity back to editor. The whole thing is manageable from the script itself. I have implemented the below code for your reference. It is only applicable for pages. You can modify as per your requirement -
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);
}