---
title: "SDK: Consuming Data (Advanced)"
slug: "flow-steps-rule-steps-advanced-consuming-data"
description: "This document shows how to create code for an advanced step that inherits from IDataConsumer, so that you can map input data at run time. The document's example shows a code for a single text input as well as an array text input."
updated: 2024-08-07T12:55:07Z
published: 2024-08-07T12:55:07Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.decisions.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SDK: Consuming Data (Advanced)

**Version 7.x .NET Architecture Change**

- Versions 7.0.1 - 7.1 require [.NET Core 3.1](https://dotnet.microsoft.com/en-us/download/dotnet/3.1)
- Versions 7.2 - 7.9 require [.NET 5](https://dotnet.microsoft.com/en-us/download/dotnet/5.0)
- Versions 7.10+ require [.NET 6](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)

## Overview

When writing an advanced step, the class must inherit from IDataConsumer for the step to have input data that can be mapped in at runtime. The below line of code illustrates a class that inherits from IDataConsumer.

```csharp
public class SampleFlowStepInputs: BaseFlowAwareStep, ISyncStep, IDataConsumer
```

Decisions has a [Public GitHub Repository](https://github.com/decisions-com/sdk-examples) with various SDK examples available.

## Example

After inheriting from IDataConsumer, the interface will need to be implemented. The implementation of this interface returns an array of DataDescription[]. The below sample code illustrates two inputs: single text input and an array text input.

The names of these inputs are set to a constant string variable. This is not necessary but is a best practice since this value refers to the input data in the run method of the created step.

```csharp
 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)
        };
    }
}
```

### Consuming Data for Flow step

The input value of a 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 code example below, the variables valueOfTextInput and valueOfTextArrayInput[] have been populated with the respective input data.

```csharp
  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

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 to this.AnchorData.Name.

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

```csharp
 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);
}
```
