Parameter edit form for Action, Condition or Rule.

Table of contents

  1. General information
  2. Parameter edit form description in the designer
  3. Single value parameter
  4. Parameter edit form description on the server - IDesignerParameterFormatProvider
  5. Substitutions

General information

Table of contents

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

Table of contents

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.

Table of contents

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

Table of contents

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());

Substitutions

Table of contents

The parameter value for Action, Action-Condition, Code Action or Rule is always JSON. Even if a form is used to edit this parameter, it is still JSON. In the JSON, the process parameter values can be substituted. The syntax of substitutions is very similar to the syntax of expressions.

  • @ParameterName - the easiest option, the parameter value named 'paremeterName' is substituted from the process. Converting to a string is done with a simple call of .ToString ().
  • @ObjectParameter.ObjectProperty.StringProperty - partial parameters can be used in the expression. That is, if you have a complex, multi-level object stored in the parameter, you can substitute a part of this object.
  • @ParameterName:formatString - expression with a format string. A string formatted according to the formatString template is substituted using the format syntax for the .NET platform. Please, for more details see here.
  • @(ParameterName:formatString) - if different special characters and delimiters are used in the format string, you must additionally enclose the expression in round brackets.
  • @ObjectParameter.ObjectProperty.IntProperty:json - special formatting when a JSON is used as the JSON value of the action parameter.

Here are some examples to illustrate substitutions.

Suppose, an object named 'Document' is saved in the process parameters in the following form:

var Document = new {
    Amount = 42,
    Name = "Some Document",
    Number = 142,
    CreateDate = DateTime.Today //17-06-2020
}

The JSON parameter value is:

{
    Amount : "@Document.Amount:json", //we need in here
    Number : "@Document.Number", //we string here in here
    Titel : "@Document.Name number @Document.Number year @Document.Date:yyyy month @Document.Date:MM day @Document.Date:dd"
}

Then, after the substitution, we get the resulting JSON:

{
    Amount : 42,
    Number : "142", //we string here in here
    Titel : "Some Document number 142 year 2020 month 06 day 17"
}
Top