Edit

Create fulfillment provider

This article describes the steps required to create a fulfillment provider in Microsoft Dynamics 365 Intelligent Order Management.

Create new provider definition

To create a new provider definition, follow these steps:

  1. Go to Providers > Catalog.
  2. Select New Provider Definition.
  3. For Display Name, enter "IOMLabFulfillmentProvider".
  4. For Logical Name, enter "msdyn_IOMLabFulfillmentProvider".
  5. For Description, enter "IOM lab fulfillment provider".
  6. For Logo, select "IOMLab.png".
  7. For Service Type, enter "Fulfillment".
  8. Select Save and close.

Add provider definition to solution

To add a provider definition to the solution, follow these steps:

  1. Go to the Power App Maker portal and navigate to the newly created solution IOMLabProviders.
  2. Select Add existing > IOM Provider Definition.
  3. Select IOMLabFulfillmentProvider and then select Add to add it to the solution.

Create provider action to send a fulfillment payload to Outlook

To create a provider action that sends a fulfillment payload to Outlook, follow these steps:

  1. Go to the Power App Maker portal and navigate to Solutions.

  2. Open the Default Solution.

  3. Select New.

  4. Select Cloud Flow, and then name it "IOM Lab Send To Fulfillment (Outlook)".

  5. Select the trigger type as HTTP trigger

    1. Define a Power Automate trigger. Typically, this trigger is an HTTP endpoint that acts as a webhook trigger (recommended), connector trigger, or a Dataverse insert trigger. The trigger starts when an external service sends data to Intelligent Order Management.

    Screenshot of trigger for when an HTTP request is received.

    Use the following JSON Schema in your HTTP trigger.

    {
        "type": "object",
        "properties": {
            "text": {
                "title": "ProviderActionExecutionEventId",
                "type": "string",
                "x-ms-dynamically-added": true,
                "description": "Please enter your input",
                "x-ms-content-hint": "TEXT"
            },
            "text_1": {
                "title": "EntityRecordId",
                "type": "string",
                "x-ms-dynamically-added": true,
                "description": "Please enter your input",
                "x-ms-content-hint": "TEXT"
            }
        },
        "required": [
            "text",
            "text_1"
        ]
    }
    

Screenshot of variable initialization actions.

  1. Add a Try scope.

  2. Within the Try scope, add a Perform an unbound action action as follows:

    • ProviderActionExecutionEventId: Under Dynamic content, select ProviderActionExecutionEventId.
    • PowerAutomateRunId: Specify the following as an expression: workflow()['run']?['name'].

    Screenshot of Try scope configuration.

  3. Add a Get a row by ID action and then do the following:

    • For Table name, enter "Fulfillment Orders".
    • For Row ID, select EntityRecordId under Dynamic content.

    Screenshot of Get a row by ID action configuration.

  4. Add a Send an email action from the Outlook.com connector, as follows. There are couple of email connectors, make sure to select Outlook.com since that's the connection set up earlier.

    • On the To line, "placeholder@placeholder.com" is used as placeholder text. This text is replaced by a provider parameter in later steps.
    • On the Subject line, "name" is obtained from the Get fulfillment order step under Dynamic content.
    • For Body, specify the following as an expression: outputs('Get_fulfillment_order')['body']

    Screenshot of Send an email action configuration.

  5. Add a List rows action as follows:

    • For Table name, enter "Fulfillment Order Products".
    • For Fetch Xml query enter the following:
    <fetch>  
      <entity name="msdyn_fulfillmentorderdetail">  
       <all-attributes />
         <filter>
         <condition attribute="msdyn_fulfillmentid" operator="eq" value="@{triggerBody()['text_1']}"/>
         </filter>
      </entity>  
    </fetch>
    

    Screenshot of List rows action configuration.

  6. Add an Apply to each control with a Send an email action as follows:

    • value is obtained from the Get fulfillment order line step under Dynamic content.
    • name is obtained from the Get fulfillment order line step under Dynamic content.
    • Current item is selected from under Dynamic content.

    Screenshot of Apply to each control configuration.

  7. Within the loop, add an Append to array variable action as follows:

    • For Name, enter "ProcessedFulfillmentOrderLines".
    • For Value, select Fulfillment line ID from under Dynamic content.

    Screenshot of Append to array variable action for fulfillment order lines.

  8. Within the loop, add another Append to array variable action as follows:

    • For Name, enter "ProcessedSalesOrderLines".
    • For Value, select Sales line ID from under Dynamic content.

    Screenshot of Append to array variable action for sales order lines.

  9. Collapse the Try scope by selecting its title bar.

  10. Select New step and add another scope named "Catch".

  11. On the Catch scope, select the ellipsis ("..."), select Configure run after, and configure as follows:

    • Select the has failed checkbox.
    • Select the has failed checkbox.

    Screenshot of Catch scope configuration.

  12. In the Catch scope, select Add an action and add a Set variable action. Rename the action to "Set the execution result to failed".

  13. Configure the properties as follows:

    • For Name, enter "ExecutionResult".
    • For Value, enter "false".

    Screenshot of Set variable action configuration.

  14. Select New step, and add another scope named "Finally".

  15. On the Finally scope, select the ellipsis ("..."), select Configure run after, and configure as follows:

    • Select the is successful checkbox.
    • Select the has failed checkbox.
    • Select the is skipped checkbox.
    • Select the has failed checkbox.

    Screenshot of Finally scope configuration.

  16. In the Finally scope, add a "condition" step and compare the ExecutionResult variable to true as follows:

    • In the first field, select the ExecutionResult variable.
    • In the second field, select is equal to.
    • In the third field, select true.

    Screenshot of condition step configuration.

  17. In the If yes branch, add a Run a child flow action and rename it "Raise Business Events for processed fulfillment order lines".

  18. Configure the properties as follows:

    • For Child flow, enter "IOM Raise Business Event".
    • For BusinessEventDefinitionId, enter "063d85c8-60a4-eb11-9443-000d3a313675".
    • For EntityRecordId, specify the following as expressions: string(variables('ProcessedFulfillmentOrderLines'))

    Screenshot of Run child flow action for business events.

  19. In the If yes branch, add another Run a child flow action and rename it "Raise Sales Order Aggregated Events".

  20. Configure the properties as follows:

    • For LineBusinessEventDefinitionId, enter "ccf64002-61a4-eb11-9443-000d3a313675".
    • For LineRecordId, specify the following as an expression: string(variables('ProcessedSalesOrderLines')).
    • For OrderBusinessEventDefinitionId, enter "48688716-61a4-eb11-9443-000d3a313675".

    Screenshot of Run child flow action for aggregated events.

  21. Collapse the condition step.

  22. Add a Perform an unbound action action as follows:

    • For Action name, enter "msdyn_CompleteProviderActionExecution".
    • For ExecutionResult, select the ExecutionResult variable from under Dynamic content.
    • For ProviderActionExecutionEventId, select ProviderActionExecutionEventId from under Dynamic content.

    Screenshot of Perform an unbound action configuration.

  23. Select Save.

Add a provider definition logic definition to the Outlook provider definition

To add a provider definition logic definition to the Outlook provider definition, follow these steps:

  1. Go to Providers > Catalog.
  2. Select the newly created IOMLabFulfillmentProvider.
  3. Select Edit on the menu bar.
  4. Select the Logic definitions tab.
  5. Select + New IOM Provider Definition Logic Definition.
  6. For Display Name, enter "IOM Lab Send to Fulfillment (Outlook)".
  7. For Logical Name, enter "msdyn_LabSentToFulfillmentOutlook".
  8. For Provider Definition, enter "IOMLabFulfillmentProvider".
  9. For Logic Type, enter "Provider Action".
  10. For Workflow Name, enter "IOM Lab Send to Fulfillment (Outlook)".
  11. For Timeout Minutes, enter "2".
  12. For Max Retry Attempts, enter "3".
  13. For Description, enter "IOM Lab Send to Fulfillment (Outlook)".
  14. For Action Type, enter "Send to Fulfillment".
  15. Select Save. This action generates a JSON representation of the message handler cloud flow and populates the Client Data field.
  16. Replace the placeholder email with provider parameter as follows:
    1. Copy the text block in the Client Data field and paste it into Notepad.
    2. In the text block, find "placeholder@placeholder.com" and replace it with "{{IOMLabOutboundFulfillmentEmail}}".