SDK: Flow Steps (Basic)
  • 25 Oct 2024
  • 1 Minute to read
  • Dark
    Light

SDK: Flow Steps (Basic)

  • Dark
    Light

Article summary

Overview

Developers can easily create custom Flow and Rule steps by methods in a Class Library (.NET Core) project. This article will show users how to accomplish this. For more examples 

Prerequisites
  • Knowledge of the desired integrated development environment (IDE) for development
  • Understanding of SDK in Decisions. To learn more, visit SDK Overview and SDK Basics.
  • Custom steps will be located and stored at C:\Program Files\Decisions\Decisions Server\modules\Decisions.Local\CoreServiceDlls

Basic Flow Step

The below code example will create a Flow step that checks if a string is 5 digits long. For more examples, check the Public GitHub Repository for Decisions.

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 Glossary 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 SnippetWhat it does
using DecisionsFramework.Design.FlowDecisions 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 trueThe output of this step
return falseThe 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 Software Development Kit (SDK) Overview.

Custom code needs to be saved here: C:\Program Files\Decisions\Decisions Server\modules\Decisions.Local\CoreServicesDlls
  1. Create a new Flow.
  2.  In the Steps panel, navigate to SDK > ZipCode. 
  3. Drag and drop the custom Is Zip Code Valid step onto the workspace. 
  4. 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. 
  5. Click Unknown and select Constant as the mapping type, and type in a 5-digit zip code.
  6. Click Save to save changes to the Flow.

Debug

  1. Click Debug on the top action bar. In the debugger, the Flow runs using "23322" as the input for the Rule step, and the step outputs as True.

For further information on SDK, visit the Decisions Forum.



Was this article helpful?