Type Converters
Type Converters allow you to convert one data type to another within a workflow. An example of using a type converter would be converting the login name of a Person (string) to PersonID (integer). This article demonstrates using a type converter in this way.
Adding a Type Converter to a Workflow
-
Open the workflow to which you want to add a type converter.
-
Right-click on the Workflow Designer and select Workflow Binding Type Converters.
-
Name the Type Converter appropriately and click Add.
-
Click Close to close the Type Converters window.
-
Locate the class for the Type Converter in the Code Tree and double-click on the ConvertTo() method to open the C# Editor for it.
-
In the C# Editor, replace the default code for the method with code that retrieves a value of type string and returns a value of type int. In this example, we specifically enter code to do the following:
- Retrieve the Person object by the login name passed to the type converter.
- Return the PersonID from the retrieved Person object.
Person p = Person.GetByLogin(value.String());
return p.PersonID;
The below image shows what the code looks like in the editor.
-
Click the External Rules tab located above the C# Editor and expand the Business Rule Engine tree to locate the property you need to convert to the new data type.
-
Drag the type converter from the Code Tree onto the node for the property you need to convert.
This binds the Converter to the property.