SDK: Flow Steps (Basic)
- 07 Jun 2021
- 2 Minutes to read
- Print
- DarkLight
This documentation version is deprecated, please click here for the latest version.
SDK: Flow Steps (Basic)
- Updated on 07 Jun 2021
- 2 Minutes to read
- Print
- DarkLight
Article summary
Did you find this summary helpful?
Thank you for your feedback
Overview
Developers can easily create custom Flow and Rule steps to be used in Decisions by methods in a Class Library (.NET Core) project. This article will show users how to accomplish this.
See the Public GitHub Repository with the various SDK examples available.
Example
This example will demonstrate how to make a project that will test to see if a Zip Code is valid.
Visual Studio 2019 will be used throughout the SDK documentation.
- Begin in Visual Studio and create a Class Library (.NET Core). In the Solution Explorer, add the DecisionsFramework.dll.Learn how to create a project in Visual Studio, how to add Decisions specific references, and how to insert a .dll into Decisions with the Get Started in Visual Studio article.
- After adding the DecisionsFramework reference, type the following code into Visual Studio. This code checks to see if a string is 5 digits long.This code uses the AutoRegisterMethodsOnClass attribute which will allow the code to show as a Flow step in the Steps panel. This attribute and others are further explained in the AutoRegister Attribute article.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using DecisionsFramework.Design.Flow; namespace ShippingExtensions { [AutoRegisterMethodsOnClass(true, "SDK/ZipCode")] public class ZipCodeManagement { public bool IsZipCodeValid(string zipCode) { if (zipCode.Length ==5) { foreach (char eachChar in zipCode.ToCharArray()) { if (Char.IsDigit(eachChar) == false) { return false; } } return true; } return false; } } }
Code Snippet What it does using DecisionsFramework.Design.Flow Decisions reference [AutoRegisterMethodsOnClass(true, "SDK/ZipCode")] This attribute will allow the code to show as a Flow step in the Steps panel. "SDK/ZipCode" will be the categories that this step is nested in within. IsZipCodeValid(string zipCode) This will be the name of the step and (string zipCode) will be the input. return true The output of this step return false The output of this step
Using the Method in Decisions
After writing the method to build the project, add it to Decisions by following the steps in Getting Started in Visual Studio.
Custom codes need to be saved here: C:\Program Files\Decisions\Decisions Services Manager\modules\Decisions.Local\ServicesDlls
- Log into the Decisions Studio and create a new Flow. In the Steps panel, navigate to SDK > ZipCode.
- Drag and drop the custom Is Zip Code Valid step onto the workspace.
- This step displays as a Rule step with a True and False outcome as stated in the method written. The step also has the Zip Code input that is expecting a string.
- Click Unknown and select Constant as the mapping type and type in a 5 digit zip code.
- Click Save to save changes to the Flow.
Debug
- Click Debug on the top action bar. In the debugger, the Flow runs using "23322" as the input for the Rule step the step outputs as "True" as expected.
Learn how to Debugging Server-Side Code in Visual Studio. It is important to know that this method was used primarily for an example. Developers can write any type of method that is logical for their specific use case.
Was this article helpful?