Skip to main content

Autocomplete setting in the designer using IDesignerAutocompleteProvider

Sometimes it is very useful to give a small tip to the user, who is editing the scheme, to prompt him which value to specify for the parameter transferred into Action, Condition or Rule. Very often you've got a CheckRole Rule, which checks if a user executing the command has a role with the name transferred into the parameter (Value column in the designer). This is how it looks in the designer:

CheckRole rule

It is only logical that the system must show a list of roles a user can choose from. To realize that function, you need to do the following:

  • write a class implementing the IDesignerAutocompleteProvider interface. Like this one, for example:

    public class AutoCompleteProvider : IDesignerAutocompleteProvider
    {
    public List<string> GetAutocompleteSuggestions(SuggestionCategory category,
    string name, string schemeCode)
    {
    if (category == SuggestionCategory.RuleParameter && name == "CheckRole")
    {
    return new List<string>(){"BigBoss", "Accountant"};
    }

    return null;
    }
    }

You can see from this code that you need to implement one method only - GetAutocompleteSuggestions. Input parameters for this method are:

  • category - enumeration, which defines a scheme element the autocomplete list is called for. Possible values: RuleParameter, ActionParameter or ConditionParameter.
  • name - Action, Condition or Rule name, the autocomplete list is displayed for. In this case autocomplete will work only if you have chosen the CheckRole Rule.
  • schemeCode - the scheme code.
  • specify your Autocomplete provider when configuring WorkflowRuntime
runtime.WithDesignerAutocompleteProvider(new AutoCompleteProvider());

After that a drop-down list of tips will be available to users. It will look like that:

Suggestions