Rule steps (simple)
  • Updated on 11 Dec 2013
  • 1 minute to read
  • Print
  • Dark
    Light

Rule steps (simple)

  • Print
  • Dark
    Light

Summary
You can easily create new rules to be used in Decisions by creating public methods 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

Visual Studio 2017 is being used in this example. Create a new  Class Library project is Visual Studio. To add the Decisions SDK, in the  Project Solution window, right click your project and go to  Manage NuGet Packages. Under the browse tab search for  DecisionsSDK.

DownloadDecisionsSDK-1.png

Decorate your class with the following attribute: [AutoRegisterMethodsAsRuleSteps(true, "Date Rules")]
Create a public method in your class that performs the checks you want to returns a bool. This method will become a rule in Decisions. The name of your method will be the name of your rule. Also the inputs of your method will become the inputs of your rule. See the following code for an example method in a class that we will use to create a rule inside of Decisions. ```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DecisionsFramework.Design.Flow;

namespace ClassLibrary_BuildingRuleSteps
{
[AutoRegisterMethodsAsRuleSteps(true, "Date Rules")]

public class SampleRules
{
    public bool SelectedDayEqualsCurrentDay(DateTime dateToCheck)
    {
        return (dateToCheck.DayOfWeek == DateTime.Now.DayOfWeek);
    }
}

}

After you have written your method build, your project and follow the steps here: [Deploying server side extensions](http://documentation.decisions.com/sdk/deploying-server-side-extensions) 

After deploying your code log into the Decisions portal and create a new rule. You will see the methods from your class in the list of available rule conditions.


![CustomRuleStep-1.png](https://cdn.document360.io/6ef8bcc1-6489-4486-9ad1-83acff7e5df0/Images/Documentation/CustomRuleStep-1.png){height ="618" width="969"}


NOTE: classes tagged as rule steps can also be tagged to show up as flow steps. For more on how to tag classes to show up as flow steps see [Flow steps (simple)](http://documentation.decisions.com/sdk/flow-steps-simple) 

Was this article helpful?