Working with Process Definitions from code
In addition to using the Visio Workflow Designer to create, edit and otherwise manage Process Definitions, you can also perform these tasks from code, by interacting with either the TOM.NET API or the Core Service. This topic provides some simple example code to illustrate how such interaction would work.
- TOM.NET API
-
The following code fragment shows some simple interaction with TOM.NET. The code uses the classes
TridionProcessDefinitionandTridionActivityDefinition, both located in the Tridion.ContentManager.Workflow namespace.TridionProcessDefinition pd = new TridionProcessDefinition(Session, tomParentPublication.Id); pd.Title = GetUniqueTitle(); TridionActivityDefinition tad1 = new TridionActivityDefinition(tomParentPublication); tad1.Title = GetUniqueTitle("Step1"); tad1.Description = tad1.Title; tad1.Assignee = Group.GetEveryoneGroup(Session); TridionActivityDefinition tad2 = new TridionActivityDefinition(tomParentPublication); tad2.Title = GetUniqueTitle("Step2"); tad2.Description = tad2.Title; tad2.Assignee = Group.GetEveryoneGroup(Session); tad1.NextActivityDefinitions.Add(tad2); pd.ActivityDefinitions.Add(tad1); pd.ActivityDefinitions.Add(tad2); pd.Save(); - Core Service
-
Here is a Core Service code fragment showing the construction of a Process Definition (Core Service called from C# .NET client code).
TridionProcessDefinitionData processDefinitionData = new TridionProcessDefinitionData { Id="tcm:0-0-0", Title = "Sample Process Definition", LocationInfo = new LocationInfo { OrganizationalItem = new LinkToOrganizationalItemData { IdRef = "tcm:0-4-1" } } }; processDefinitionData.ActivityDefinitions = new[] { new TridionActivityDefinitionData { Id="tcm:0-0-0", Title = "Sample Activity", Description = "Sample Activity", Assignee = new LinkToTrusteeData { IdRef = "tcm:0-1-65568" } } }; ClientAdmin.Create(processDefinitionData, null);