SDK: Property Editor Basics Specifying Editors
  • 25 Jan 2022
  • 1 Minute to read
  • Dark
    Light
  This documentation version is deprecated, please click here for the latest version.

SDK: Property Editor Basics Specifying Editors

  • Dark
    Light

Article summary

Version 7.x .NET Architecture Change

Overview

How a Property Editor is displayed can be changed in Decisions. For example, a Property Editor that appears as a text box may be converted to a drop down menu. These changes can be made by decorating properties with Property Editor attributes.

Example

This example will demonstrate how to write a step that has a property called Level which will allow users to select from three levels. 

Decorate the Level property with the following attribute:

[SelectStringEditor(new string[] {"Level 1", "Level 2", "Level 3"}, SelectStringEditorType.DropdownList)]
If the Level property was not decorated with this attribute, it would show up in the designer looking like this:


After decorating, the property will show up in the designer looking like this:


Another property can be created that supplies the values to this attribute. This is useful when the desired outcome is to dynamically fetch the possible values at design time. Below is an example showing how this can be done.

[SelectStringEditor("AvailableLevels", SelectStringEditorType.DropdownList)]
public string Level;

[PropertyHidden]
private string[] AvailableLevels => new string[] { "Level 1", "Level 2", "Level 3" };


The above example shows how to set a property editor on a property. A Property Editor can also be set on an input parameter to a simple method step. To do this, place the desired editor attribute directly before the desired parameter name to apply it to. Notice how the [PasswordTextAttribute] is applied to the string password input parameter below.

[AutoRegisterMethodsOnClass(true, "Sample Steps", RegisterForAgents = true)]
public class SampleInputPropertyEditorSteps
{
   public void SampleInputPropertyEditorStep(string username, [PasswordText] string password)
   {
       //do something
   }
}

Doing this will cause the password editor to show up when selecting a Constant mapping type.


Was this article helpful?