Where you ever annoyed with the ActivityFinish class? Namely, that second parameter nextAssignee of type Trustee of the constructor?
The constructor signature is the following:
public ActivityFinish(string message, Trustee nextAssignee, Session session);
So what do I pass as nextAssignee? Figuring that out is not easy... Luckily though, you can simply pass null for the assignee and Tridion will then use the user/group that is defined in the Activity Definition (in the Workflow Visio diagram).
What if I want to properly assign a nextAssignee? How do I figure out who the next assignee should be? Well, one way I used in the past was to identify the last manual Activity (thus not automatic, because they are performed by the implicit Tridion user as defined in the SDL Tridion Content Manager MMC snap-in / Workflow settings / Automatic Trustee ID). Then I used this Trustee for the ActivityFinish.
Alternatively, as shown by the code-below, I identify the next activity, then take its implicit assignee and use that:
String lastManualActivityMessage = GetLastManualActivityMessage();
Some methods above, like GetLastManualActivityMessage(), GetNextActivityDefinition(), will be presented in some next posts.
The code sample above are part of YAWF (Yet Another Workflow Framework).
The constructor signature is the following:
public ActivityFinish(string message, Trustee nextAssignee, Session session);
So what do I pass as nextAssignee? Figuring that out is not easy... Luckily though, you can simply pass null for the assignee and Tridion will then use the user/group that is defined in the Activity Definition (in the Workflow Visio diagram).
What if I want to properly assign a nextAssignee? How do I figure out who the next assignee should be? Well, one way I used in the past was to identify the last manual Activity (thus not automatic, because they are performed by the implicit Tridion user as defined in the SDL Tridion Content Manager MMC snap-in / Workflow settings / Automatic Trustee ID). Then I used this Trustee for the ActivityFinish.
Alternatively, as shown by the code-below, I identify the next activity, then take its implicit assignee and use that:
String lastManualActivityMessage = GetLastManualActivityMessage();
ActivityDefinition nextActivityDefinition =
GetNextActivityDefinition();
ActivityInstance activityInstance =
CurrentWorkItem.Activity as ActivityInstance;
Trustee nextActivityAssignee = null;
if (nextActivityDefinition == null) { // last activity
Logger.Info("FinishActivityHandler:
This '{0}' is the last activity in the Workflow",
Info.ActivityDefinitionTitle);
Info.ActivityDefinitionTitle);
} else { // there is next activity
nextActivityAssignee
= nextActivityDefinition.Assignee;
if (nextActivityAssignee == null)
{
Logger.Warn("FinishActivityHandler:
Cannot find assignee for next activity '{0}'",
nextActivityDefinition.Title);
nextActivityDefinition.Title);
}
}
ActivityFinish activityFinish = new ActivityFinish(lastManualActivityMessage,
nextActivityAssignee, Util.Session);
nextActivityAssignee, Util.Session);
activityInstance.Finish(activityFinish);
Some methods above, like GetLastManualActivityMessage(), GetNextActivityDefinition(), will be presented in some next posts.
The code sample above are part of YAWF (Yet Another Workflow Framework).
Comments