Implementing multiple output in the workflow adapter

To implement multiple output in the custom workflow action adapter for a custom workflow action, you must configure the adapter to use the dependency properties for multiple output added to the corresponding custom workflow activity. For more information about implementing multiple output in workflow activities, see Implementing multiple output in the workflow activity.

To add error handling to a workflow adapter

  1. In the GetDefaultConfig method of the workflow adapter class, invoke the EnableConfig method from the MultiOutputUtil helper class, using the NWActionConfig class instance for the adapter. The workflow adapter class is the class in the workflow adapter that is derived from the GenericRenderingAction base class.

    public override NWActionConfig GetDefaultConfig(
      GetDefaultConfigContext context)
    {
      // Define the default configuration for the workflow adapter.
      NWActionConfig config = new NWActionConfig(this);
    
      // Enable the default configuration to support
      // multiple output. 
      MultiOutputUtil.EnableConfig(config);
      
      // Finish defining the default configuration.
      
      // Return the default configuration.
      return config;
    }
    
  2. In the AddActivityToWorkflow method of the workflow adapter class, invoke the EnableActivity method of the MultiOutputUtil helper class, to identify the ValueStorageCollection property that contains the list of values to retrieve for the custom workflow action.

    Caution: The EnableActivity method must be called after the workflow activity has been added to the Activities collection of the parent activity; otherwise, an error occurs.

    public override CompositeActivity AddActivityToWorkflow(
      PublishContext context)
    {
      // Get the configuration parameters for the workflow adapter, and then
      // instantiate the workflow activity.
      Dictionary<string, ActivityParameterHelper> parameters = 
        context.Config.GetParameterHelpers();
      CustomActivity activity = new CustomActivity();
    
      // Set the error handling values.
      if (context.Config.ErrorHandling != null)
      {
        context.Config.ErrorHandling.AssignTo(
          (Activity)activity,
          CustomActivity.CaptureErrorsProperty,
          CustomActivity.ErrorOccurredOutputProperty,
          CustomActivity.ErrorMessageOutputProperty,
          context);
      }
    
      // Finish adding the workflow activity to the workflow.
      context.ParentActivity.Activities.Add(activity);
      
      // Invoke the EnableActivity method only after the workflow activity has been added 
      // to the parent activity collection.
      MultiOutputUtil.EnableActivity(activity, CustomActivity.MultiOutputInfoProperty, context);
    
      return null;
    }
  3. In the GetConfig method of the workflow adapter class, invoke the SetMultiOutputInfoInConfig method of the MultiOutputUtil helper class, to retrieve the multiple output configuration from the workflow activity.

    public override NWActionConfig GetConfig(RetrieveConfigContext context)
    {
      // Read the properties from context.Activity and update the values 
      // in the NWActionConfig object.
      NWActionConfig config = this.GetDefaultConfig(context);
      Dictionary<string, ActivityParameterHelper> parameters = config.GetParameterHelpers();
    
      // Get the multiple output configuration.
      MultiOutputUtil.SetMultiOutputInfoInConfig(
        config, CustomActivity.MultiOutputInfoProperty, context);
    
      // Finish retrieving configuration values.
      return config;
    }
  4. In the ValidateConfig method of the workflow adapter class, invoke the ValidateConfigForMultiOutput method of the MultiOutputUtil helper class, to validate the multiple output options for the custom workflow action. The configuration is not valid if any value is specified more than once in the ValueStorageCollection object, or if a value does not have a corresponding workflow variable assigned to it.

    Tip: The ValidateConfigForMultiOutput method is overloaded, to provide the capability to modify the validation behavior if needed.

    public override bool ValidateConfig(ActivityContext context)
    {
        bool isValid = true
        
        // Prepare a keyed collection of ActivityParameterHelper objects.
        Dictionary<string, ActivityParameterHelper> parameters = 
            context.Configuration.GetParameterHelpers();
        
        // TODO: Invoke the Validate method for each ActivityParameterHelper.
        
        // Validate the multiple output configuration.
        // The validationSummary object is a protected member from the GenericRenderingAction class
        if(!MultiOutputUtil.ValidateConfigForMultiOutput(config, validationSummary))    
        {
            isValid = false;
        }
    
        // Return whether the configuration is valid.
        return isValid;
    }

See Also

Concepts

Workflow activities

Workflow action adapters

Operations

Working with workflow actions

Working with workflow activities