• Sayantan Basu

Implementation Of “Auto Approval Functionality” In Tridion Workflow

In my last blog I have already discussed about the Simple Workflow (Auto Publish to Live) in Tridion. Today I will show you how to implement auto approve functionality in Tridion workflow. If you are familiar with the process of creating workflow in Tridion then it is ok otherwise I will recommend you to check my previous blog.

Scenario:

Sometimes you will get the requirement of implementing auto approval functionality in Tridion workflow. It means if an activity is waiting for long time then you can skip that activity and send it for next phase.

Implementation:

This is very easy to implement with the new feature enabled in the Visio Workflow designer in Tridion 2013. A new method called Expire has been implemented to the ExternalActivity base class.

The facility of this method is it will be executed when the Activity Due date is reached and the activity hasn’t been finished or even started.

Tricks:

First create your workflow


Here are some sample implementation for an Expiration Script. One interesting thing to notice here is that I am specifying an expiration script for a manual decision activity, so now we can include some sort of automation for manual as well as automatic activities now.


As per the example my activity will be expired within 1 Minute. But you can implement it as per your requirement. Now you have to specify the Expiration Script Type. Here I am using External Activity.

Here is the Expiration Script –


Now the coding part comes into the picture.

Create a class by inheriting ExternalActivity (base class).

class AutoApprovedForDecission : ExternalActivity

Override the Expire Method

protected override void Expire() {}

As I am using decision activity here so instead of using ActivityFinishData here I have used DecisionActivityFinishData.

var decisionActivityFinishData = new DecisionActivityFinishData { NextActivity = new LinkToActivityDefinitionData { IdRef = nextActivityId } }; CoreServiceClient.FinishActivity(ActivityInstance.Id, decisionActivityFinishData, null);

Here is the full code –

class AutoApprovedForDecission : ExternalActivity { public string nextActivityId; ReadOptions readoption = new ReadOptions(); protected override void Expire() { TridionActivityDefinitionData activitydefinition =         (TridionActivityDefinitionData)CoreServiceClient.Read(ActivityInstance.ActivityDefinition.IdRef, readoption); ProcessDefinitionData processdefinition = (ProcessDefinitionData)CoreServiceClient.Read(activitydefinition.ProcessDefinition.IdRef, readoption); IList<ActivityDefinitionData> activityDefinitions = new List<ActivityDefinitionData>(processdefinition.ActivityDefinitions); foreach (var activity in activityDefinitions) { if (activity.Title == “Put the Title of Next Activity”) { nextActivityId = activity.Id; } } var decisionActivityFinishData = new DecisionActivityFinishData { NextActivity = new LinkToActivityDefinitionData { IdRef = nextActivityId } }; CoreServiceClient.FinishActivity(ActivityInstance.Id, decisionActivityFinishData, null); } }

Thanks and Keep checking my blogs for future update.

#TridionWorkflow

© 2019 by Sayantan Basu