Parameter edit form for Action, Condition or Rule.

These functions are available in Workflow Engine ≥ 4.0

Parameter which is transferred into Action, Condition or Rule can be a complex JSON object, that is why it might be useful to help user fill in this object. In WFE you can specify a form which will be displayed in the designer when editing this parameter. There are two ways to describe this form:

  • for Actions, created in the designer (Code Actions), you can describe the parameter form in the designer (i.e. in the scheme), or write a class implementing the IDesignerParameterFormatProvider interface and connect it to WorkflowRuntime on the server.
  • for Actions, implemented into the Action provider or Rule provider you can use IDesignerParameterFormatProvideronly.

Parameter edit form description in the designer

Parameter edit form window is called from the Code Actions window in the designer. Each described form is bound to the specific Code Action.

Code action window

You can create fields of the following types:

  • Text - string input field
  • Number - any number
  • Checkbox - checkbox field; if the field is non-required, the form will show a three state checkbox - checked,unchecked,undefined. If the field is required, the form will show a two state checkbox - checked, unchecked.
  • Dropdown - field with a dropdown list to choose a value
  • Date/Time - date and time in the ISO 8601 format (for example, 2005-08-09T18:31:42)
  • Json - any valid JSON You need to specify name for each field. You can mark the field as required, and the edit form will check if this field has been filled. You can also set value by default for each field.

Edit parameter window

Parameter edit form is opened upon clicking the Edit value in JSON button.

Edit parameter button

If no parameter edit form has been specified for a certain Code Action, the JSON editor window will open. If it has been specified - the edit form will open.

Edit parameter form

You can always switch into the JSON editor from the edit form and edit parameter value in it.

Edit parameter Json

Single value parameter.

Sometimes the parameter transferred into Action, Condition or Rule is a single value, not a complex JSON (for example, number, string, true or false). To be created, the parameter input form must consist of a single nameless field.

Single parameter window

Then there will be a single nameless parameter in the parameter edit form.

Single parameter form

Parameter value will be single, not a JSON object.

Single parameter value

Parameter edit form description on the server - IDesignerParameterFormatProvider

If you don't want to create parameter forms in the designer or if your Actions, Conditions or Rules are defined on the server, you can write server code, which will specify parameter edit forms appearance displayed in the designer.

  • write a class implementing the IDesignerParameterFormatProvider interface, for example:

    public class DesignerParameterFormatProvider : IDesignerParameterFormatProvider
    {
      public List<CodeActionParameterDefinition> GetFormat(CodeActionType type, string name)
      {
          if (type == CodeActionType.Action && name == "UpdateTransitionHistory")
          {
              return new List<CodeActionParameterDefinition>()
              {
                  new CodeActionParameterDefinition
                  {
                      DefaultValue = "Some text",
                      IsRequired = true,
                      Name = "TextParameter",
                      Type = ParameterType.Text
                  },
                  new CodeActionParameterDefinition
                  {
                      DefaultValue = "12",
                      IsRequired = false,
                      Name = "NumberParameter",
                      Type = ParameterType.Number
                  },
                  new CodeActionParameterDefinition
                  {
                      DefaultValue = "true",
                      IsRequired = true,
                      Name = "BooleanParameter",
                      Type = ParameterType.Checkbox
                  },
                  new CodeActionParameterDefinition
                  {
                      DefaultValue = "true",
                      IsRequired = true,
                      Name = "BooleanParameter",
                      Type = ParameterType.Checkbox
                  },
                  new CodeActionParameterDefinition
                  {
                      DefaultValue = "Value1",
                      IsRequired = false,
                      Name = "DropdownParameter",
                      Type = ParameterType.Dropdown,
                      DropdownValues = new List<DropdownValue>
                      {
                          new DropdownValue
                          {
                              Name = "Name1",
                              Value = "Value1"
                          },
                          new DropdownValue
                          {
                              Name = "Name2",
                              Value = "Value2"
                          }
                      }
                  },
                  new CodeActionParameterDefinition
                  {
                      DefaultValue = "2018-11-30",
                      IsRequired = true,
                      Name = "DateParameter",
                      Type = ParameterType.DateTime
                  },
                  new CodeActionParameterDefinition
                  {
                      DefaultValue = "{property1: 100,property2: \"Some string\"}",
                      IsRequired = false,
                      Name = "JsonParameter",
                      Type = ParameterType.Json
                  },
              };
          }
    
          return null;
      }
    }

    This provider example thoroughly describes the form which we have created earlier. You need to implement one method only - GetFormat, which will have the following parameters in the input:

    • type - enumeration, which defines a scheme element the parameter edit form is called for (possible values - RuleGet, Action or Condition)
    • name - Action, Condition or Rule name parameter edit form is called for. This form will be displayed only if you have chosen the UpdateTransitionHistory Action Method must return a list of fields for the form which will be displayed in the designer for parameter editing. The code above covers all types of form fields.
  • specify your Parameter format provider when configuring WorkflowRuntime

    runtime.WithDesignerParameterFormatProvider(new DesignerParameterFormatProvider());
Top