다음을 통해 공유


How to: Create a Custom Workflow Provider

Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

In Microsoft Dynamics AX, there are four workflow provider types. In some cases, the instances of these providers may not meet your application requirements. The following procedure describes the steps to implement a custom workflow provider.

You create a custom workflow provider by implementing a workflow provider interface. See Workflow Provider Interfaces for more information about the interface for each provider type. Choose the appropriate interface type for your custom provider, and implement the methods in a class using the following procedure.

To create a custom workflow provider

  1. In the AOT, expand the Classes node.

  2. Right-click the Classes node, and then select New Class. A new class group displays under the Classes node.

  3. Expand the new class, right-click classDeclaration, and then click View Code.

  4. Enter the code in the class declaration to indicate which workflow provider interface the class is implementing. The following example shows the class declaration for a workflow provider that implements the WorkflowParticipantProvider interface.

        public class <MyCustomWorkflowProviderClassName> implements WorkflowParticipantProvider
        {
        }
  1. Right-click in the Editor window, click New, and then enter the following code for one of the methods in the interface that you are implementing. For example, the following code shows the getParticipantTokens method that is part of the WorkflowParticipantProvider interface.
        public WorkflowParticipantTokenList getParticipantTokens()
        {
            // Constructs the new user group list.
            WorkflowParticipantTokenList userGroups = WorkflowParticipantTokenList::construct();
        
            // ToDo Define your user groups here.
        
            return userGroups;
        }
  1. Right-click in the Editor window, click New, and then create the next method for the workflow provider interface. The following code example shows the resolve method that is part of the WorkflowParticipantProvider interface.
        public WorkflowUserList resolve(WorkflowContext _context,
            WorkflowParticipantToken _participantTokenName)
        {
            // Declare the variables.
            UserGroupList userGroupList;
            WorkflowUserList userList = WorkflowUserList::construct();
            ;
            
            // Verify that the participant token is set or throw an error.
            if (!_participantTokenName)
                throw error("@SYS105453");
        
            // ToDo Enter code to add users to the user list.
           
            {
                userList.add(userGroupList.UserId);
            }
        
            return userList;
        }
  1. Continue implementing the methods for the workflow provider interface.

  2. Close the Editor window and then click Yes to save changes.

  3. In the AOT, expand the Workflow > Providers node.

  4. Right-click the node for the provider type for which you are creating a custom provider and then choose to create a new provider. For example, right-click the ParticipantAssignment node and then click New Participant Assignment Provider.

  5. Right-click the node for the new customer provider and then click Properties.

  6. Supply the following properties for the custom provider.

    Property

    Description

    Name

    The name for the custom provider.

    Label

    The label for the custom provider.

    HelpText

    A description for the custom provider.

    AssociationType

    Specifies whether the workflow provider is used at the company or global level.

    AvailableForAllWorkflowTypes

    Specifies whether the workflow provider can be used for all workflow types.

    ProviderClass

    The custom workflow provider class that defines the behavior of the custom provider. You created this class earlier in this procedure.

  7. If you set the AvailableForAllWorkflowTypes property to No, then you should specify which workflow types the custom provider can be used with. Expand the node for the custom provider.

  8. Right-click the Workflow Types node and then click New Workflow Type.

  9. Select the new node. In the Properties list, set the WorkflowType property to the name of the workflow type that the custom workflow provider will be used with.

  10. Save the changes for the custom provider.

See also

Workflow Providers Overview

Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.