Context Data in Nintex Workflow represent values specific to the workflow, the context of the item and the current task within the workflow. As an example below are some of them
Initiator: The username (domain\username) who caused the item to be entered into the workflow
Item URL: The URL of the item in workflow
The complete list of Contex Data items and how to manage it is described in Nintex Workflow User Manual.
Designing custom Context Data usually include the implementation of specific handler(class). In Nintex Workflow API for this purposes exist class ContextDataItemBase, from which all Context Data items usually inherits.
The implementation of Context Data for returning approvers comments in XML format is presented below
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Context DataItem for All Approvers in Xml format | |
/// </summary> | |
public class AllApproverCommentsXml : ContextDataItemBase | |
{ | |
/// <summary> | |
/// | |
/// </summary> | |
/// <param name="ctx"></param> | |
/// <returns></returns> | |
public override object GetValueObject(NWWorkflowContext ctx) | |
{ | |
return GetLastApproverCommentsAsXml(ctx); | |
} | |
internal string GetLastApproverCommentsAsXml(NWWorkflowContext ctx) | |
{ | |
return new NintexTaskCollection(ctx.InstanceID, ctx.Web).GetAllApprovalTaskCommentsAsXml(); | |
} | |
/// <summary> | |
/// Internal Name | |
/// </summary> | |
public override string InternalName | |
{ | |
get { return "AllApproverCommentsXml"; } | |
} | |
} |
Below is shown page for managing Context Data with custom Context Data added and Insert Reference dialog that demonstrates the usage of custom Context Data when designing workflow
Now our goal to automate the deployment of Context Data. For example, it is possible to create Data Context item during feature activation. For this task we’ll use method of class CustomCommonDataCollection (in namespace:Nintex.Workflow) from Nintex Workflow API:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Add(string typeName, string assemblyName, string displayName, string description) |
Adding Context Data item in Nintex Workflow Management (shown below)
is equivalent to calling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CustomCommonDataCollection.Add( | |
"SharePoint.NW2010.Deployment.ContextDataItems.AllApproverCommentsXml", | |
"SharePoint.NW2010.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b6acd7f49f7aeb64", | |
"Approver Comments (XML)", | |
"Approver comments in XML format"); |
You could grab the source code for the project that demonstrates how to provision Context Data here.