Working with custom workflow context properties
You can create your own custom workflow context properties, which can be used anywhere a workflow context property reference can be added, in Nintex Workflow 2013.
Developing custom workflow context properties
From a development perspective, a custom workflow context property is a public class, derived from the ContextDataItemBase class. The public class must meet the following requirements:
-
The public class must be derived from the ContextDataItemBase class, and it must override, at a minimum, the InternalName abstract property and the GetValueObject abstract method.
-
The public class must be contained in a signed, strongly-typed assembly.
-
The assembly must target .NET Framework 4.0.
-
The assembly must be installed into the Global Assembly Cache (GAC) on each web front end.
You can override the following properties and methods for your custom workflow context property, as needed, from the ContextDataItemBase class:
-
To add logic that determines whether it is displayed in the Insert Reference dialog, override the ShouldDisplay method. The method can use the ContextDataItemDisplayContext class to identify the context in which the custom workflow content property is about to be displayed.
-
To support localized display names, override the DisplayNameTable property.
If you want to provide localized values for the DisplayName property, override the DisplayNameTable property and provide a Dictionary<int, string> object in which the int represents locale ID (LCID) values and the string represents the locale-specific value for the DisplayName property. If the DisplayName property is not overridden, it can, in the following order:
-
If a value for which the key is set to the current locale ID exists in the DisplayNameTable property, return that value.
-
If a value for which the key is set to zero (0) exists in the DisplayNameTable property, return that value.
-
Return the value of the InternalName property.
-
-
To support localized descriptions, override the DescriptionTable property.
If you want to provide localized values for the Description property, override the DescriptionTable property and provide a Dictionary<int, string> object in which the int represents locale ID (LCID) values and the string represents the locale-specific value for the Description property. The Description property can, similar to the DisplayName property, use the DescriptionTable to provide a locale-specific value or, if a suitable value cannot be found, the value of the InternalName property.
-
To provide additional string data to a custom workflow content property, use the Data property.
The Data property allows Nintex Workflow 2013 to provide string data to a custom workflow context property, as part of its definition.
-
To specify the data type returned by the custom workflow context property, override the FieldType property.
Typically, the FieldType property returns ContextDataType.Text, indicating that the value of the custom workflow context property is a string. If your value fits one of the other ContextDataItem enumeration values, override the FieldType property and return the appropriate ContextDataItem enumeration value.
-
To add logic that determines whether it exists at startup, override the ExistAtStartup method.
Unlike the ShouldDisplay method, there is no context helper for this method.
Defining custom workflow content properties
Unlike custom inline functions, custom workflow content properties do not have aliases. The combination of a type name and an assembly name defines a custom workflow content property in Nintex Workflow 2013, and only one custom workflow content property can be defined for each combination. The definitions for all workflow context properties, including custom workflow context properties, are stored in the configuration database.
Similarly, localized values cannot be specified for custom workflow context properties when the custom workflow context property is defined in Nintex Workflow 2013.
The AddCustomDataItem operation provided by the NWAdmin.exe command line tool is used to define a custom workflow context property for NintexWorkflow 2013. For example, the following command defines a custom workflow context property, named Last Run Time, for the LastRunDateTime class included in the CustomWorkflowContextProps sample.
NWAdmin.exe -o AddCustomDataItem -type "CustomWorkflowContextProps.LastRunDateTime" -assembly "CustomWorkflowContextProps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3a6b78db44595b93" -displayname "Last Run Time" -description "The date and time at which the workflow instance was last modified."
You can use the EnumCustomDataItems operation provided by NWAdmin.exe to confirm that your custom workflow context properties are successfully defined in the configuration database, or the DeleteCustomDataItem operation to remove a custom workflow context property from the configuration database.
Caution: The DeleteCustomDataItem operation can remove any custom workflow context property. Removing a custom workflow context property deletes it from the configuration database, making it unavailable to NintexWorkflow 2013, but does not remove the corresponding assembly from the GAC.
For more information about the NWAdmin.exe command line tool, see NWAdmin Operations - Nintex Workflow 2013.
Invoking custom workflow context properties
Custom workflow context properties can be invoked just like other workflow references. For more information about using workflow context properties, see Workflow context properties.