Implementing action summaries

When a workflow action is presented in the design canvas of Workflow designer, hovering the mouse pointer over the workflow action displays the action summary pane for that workflow action. The action summary pane displays information about the workflow action, depending on the validation state of the configuration for the workflow action.

Using the ValidationSummary class

If a validation error occurs while validating the configuration for a workflow action, the action summary pane displays a warning about the validation error, as shown in the following diagram:

The information presented in the action summary pane is derived from the ValidationSummary class. The GenericRenderingAction class instantiates the ValidationSummary class in a variable named validationSummary. When the ValidateConfig method of the GenericRenderingAction class is invoked by the Workflow designer to validate a workflow action, the AddError method of the ValidationSummary class is invoked whenever a validation error is encountered. The following code illustrates an implementation of the ValidateConfig method in a custom workflow action:

public override bool ValidateConfig(ActivityContext context)
{
    bool isValid = true;

    // Prepare a keyed collection of ActivityParameterHelper objects.
    Dictionary<string, ActivityParameterHelper> parameters = 
        context.Configuration.GetParameterHelpers();
            
    // Invoke the Validate method for each ActivityParameterHelper.
    if (!parameters[PropertyName].Validate(typeof(string), context))
    {
        isValid &= false;
        validationSummary.AddError("Property name", ValidationSummaryErrorType.CannotBeBlank);
    }

    // Return whether the configuration is valid.
    return isValid;
}

If the ValidateConfig method returns false, the information in validationSummary is rendered in the action summary pane when the pane is displayed, in which each validation error is rendered depending on the type of validation error specified in the AddError method. The Render method of the ValidationSummary class is invoked to render the action summary pane.

You can customize the header and footer of the action summary pane, by setting the values of the Header and Footer properties, respectively, and retrieve the contents of the action summary pane, in HTML format, by invoking the ValidationMessage method of the ValidationSummary class.

Using the ActionSummary class

If the configuration is validated for a workflow action, the action summary pane displays information about the workflow action, as shown in the following diagram:

The information presented in the action summary pane is derived from the ActionSummary class. If the ValidateConfig method of the GenericRenderingAction class returns true, the BuildSummary method of the GenericRenderingAction class is invoked to provide an instance of the ActionSummary class. The following code illustrates an implementation of the BuildSummary method in a custom workflow action:

public override ActionSummary BuildSummary(ActivityContext context)
{
    // Prepare a keyed collection of ActivityParameterHelper objects.
    Dictionary<string, ActivityParameterHelper> parameters = 
        context.Configuration.GetParameterHelpers();

    // Construct a display message for the action summary.
    var displayMessage = string.Format("Perform an operation using value '{0}'.", 
        parameters[PropertyName].Value);

    // Return the action summary.
    return new ActionSummary(displayMessage);
}

The information in the ActionSummary class is rendered in the action summary pane when the pane is displayed. The Render method of the ActionSummary class is invoked to render the action summary pane.

You can customize the header of the action summary pane, by setting the value of the Header property, and the contents of the action summary pane, in HTML format, by setting the Summary property of the ActionSummary class.

See Also

Concepts

Workflow activities

Workflow action adapters

Configuration pages

Operations

Working with workflow actions

Working with workflow activities

Reference

.NET Framework Reference