Flow Steps and Rule Steps (Advanced) Consuming Data
  • Updated on 11 Dec 2013
  • 1 minute to read
  • Print
  • Dark
    Light

Flow Steps and Rule Steps (Advanced) Consuming Data

  • Print
  • Dark
    Light

When writing an advanced step, your class must inherit from IDataConsumer if you want your step to have input data that you can map in at run time. The below line of code illustrates a class that inherits from IDataConsumer .
public class SampleFlowStepInputs : BaseFlowAwareStep, ISyncStep, IDataConsumer After inheriting from IDataConsumer , you need to implement this interface. The implementation of this interface returns a array of DataDescription[] . The below sample code illustrates two inputs: (1) a single text input, and (2) and array text input.
Note: The names of these inputs are set to const string variable which were defined earlier in the code. This is not necessary, but is a best practice, since you'll need to use this value to refer to the input data in the run method of your step.
Note; Custom codes are located here: C:\Program Files\Decisions\Decisions Services Manager\Instances\Control\CustomReferences

 public DataDescription[] InputData
{
    get
    {
        return new DataDescription[] 
        {
            new DataDescription(new DecisionsNativeType(typeof(string)), INPUT_TEXT),
            new DataDescription(new DecisionsNativeType(typeof(string)), INPUT_TEXT_ARRAY, true, false, false)
        };
    }
}

The input value of your flow step will be consumed in the run method. The input data values will be contained in a dictionary within the run method. This dictionary is data.Data . Use the name of the input data as the key to refer to it in the dictionary as shown below. In this example we populate the variables valueOfTextInput and valueOfTextArrayInput[] with the respective input data.

 public ResultData Run(StepStartData data)
{
    string valueOfTextInput = (string)data.Data[INPUT_TEXT];
    string[] valueOfTextArrayInput = (string[])data.Data[INPUT_TEXT_ARRAY];
    return new ResultData("Done");
}

Consuming data for a rule step is much the same as a flow step with one exception. The anchor data of the rule step is automatically available inside the run method of the rule step. Therefore it does not need to be handed in separately. This anchor data is available in the data.Data dictionary with the key of this.AnchorData.Name .

The code below shows an example of a rule's run method that compares the anchor data to an additional input that was added to the rule.

 public override bool Run(RuleStepExecutionData data)
{
    string input = (string)data.Data[this.AnchorData.Name];
    string textToEval = (string)data.Data[INPUT_TEXT_TO_EVALUATE];
   return input.Equals(textToEval, StringComparison.OrdinalIgnoreCase);
}

To see a working example code from these two examples. Download the attached zip file. The file contains a project you can compile and use.

Was this article helpful?