Flow Steps and Rule Steps (Simple): Creating Custom Data Types

Last Updated: 06/18/2018 Introduced in Version: 2.0
Summary
You can easily create new datatypes to be used in Decisions by creating classes in a class file project. This article will show you how to accomplish this.
 
*Note custom codes are located here: C:\Program Files\Decisions\Decisions Services Manager\Instances\Control\CustomReferences
 
Example
In this example, Visual Studio 2017 is the IDE that is being used. Create a new Class Library project in Visual Studio. Download the Decisions SDK by right clicking your project in the  Solution Explorer and go to Manage NuGet Packages. Under the Browse tab, search for DecisionsSDK then install.
 
decisionssdk
 
Add the following using statement to your project:  using System.Runtime.Serialization;
Create a public class for your data type and decorate this class with the following attribute: [DataContract] 
Add public properties for each property you want on your class decorated with the following attribute: [DataMember] 
After adding all the properties you want, add a public parameterless constructor.
Below is an example of code that follows these patterns:

 

After you have written your classes, build your project, copy the compiled dll to  C:\Program Files\Decisions\Decisions Services Manager\modules\Decisions.Local\ServicesDlls, and restart Service Host Manager service.

Types need to be registered in order to be used in the platform.  Types are automatically registered when they are used in a flow or rule step or as part of a hosted service definition.  If you want to register a type without using it, you should call the register native type method.

 Note: only types, not array versions of types, are to be registered.

After Service Host Manager has finished restarting, log into the Decisions portal. Within any list of datatypes you will see the types you just added. As an example, you can create a new flow and use the Create Data step to view available types to select from. Within the type picker menu go to System > Designers > DataStructures. You should see the Class Library that you created in Visual Studio. Below is a sample screen shot showing how this list would look after publishing the type shown in the example code above.
 
selectclasslibrary

Additional Resources