Create an intake provider

Completed

This unit describes the steps that are required for creating an intake provider in Intelligent Order Management.

Add new providers

There are multiple providers available in Dynamics 365 Intelligent Order Management that your organization can leverage to optimize business processes. Providers allow you to seamlessly connect external systems to Intelligent Order Management.

For more information on the providers available in Dynamics 365 Intelligent Order Management, go to Provider Catalog.

Create a 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 LabOrderIntakeProvider.
  4. For Logical Name, enter msdyn_LabOrderIntakeProvider.
  5. For Logo, select Lab.png.
  6. For Service Type, enter Order intake.
  7. For Description, enter Lab order intake provider.
  8. Select Save & close.

Add a provider definition to a solution

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

  1. Go to Power Apps maker portal and go to the newly created LabProviders solution.
  2. Select Add existing > Provider Definition.
  3. Select LabOrderIntakeProvider and then select Add to add it to the solution.

Add a transformation to the provider definition

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

  1. Go to Providers > Catalog.

  2. Select the newly created LabOrderIntakeProvider.

  3. Select Edit on the menu bar.

  4. Select the Transformations tab.

  5. Select + New IOM Provider Definition Transformation.

  6. For Display Name, enter Lab Order to Dataverse Order.

  7. For Logical Name, enter msdyn_LabOrderIntake_Order.

  8. For Provider Definition, enter or select LabOrderIntakeProvider.

  9. For Source Object Name, enter LabOrderIntakeProvider.

  10. For Destination Object Name, enter Dataverse Order.

  11. For Transformation, paste in the following M query code:

     shared ImportMappingKey = [
    account = {
     		[
     			ExternalRecordKey = [ProviderName = "LabOrderIntakeProvider"],
     			SelectedFields = {"accountid"}
     		]
    },
     	pricelevel = {
     		[
     			ExternalRecordKey = [ProviderName = "LabOrderIntakeProvider"],
     			SelectedFields = {"pricelevelid"}
     		]
    },
     	product = List.Distinct(List.Transform(Source[orderdetails], each
     		[
     			ExternalRecordKey = [sku = _[sku]],
     			SelectedFields = {"productid"}
     		])),
     	uom = List.Distinct(List.Transform(Source[orderdetails], each
     		[
     			ExternalRecordKey = [unit = _[unit]],
     			SelectedFields = {"uomid"}
     		]))
    ];
    shared TransformSourceData =
    let
     orderProducts = Source[orderdetails],
     account = IOM.MapRecord(IOM.MappingTables[account], [ProviderName = "LabOrderIntakeProvider"]),
     pricelevel = IOM.MapRecord(IOM.MappingTables[pricelevel], [ProviderName = "LabOrderIntakeProvider"]),
    
     orderheader = Record.FromTable
     				(
     					Table.SelectRows
     					(
     						Record.ToTable
     						(
     							[
     								ordernumber = Text.From(Source[ordernumber]),
     								name = ordernumber,
     								#"customerid_account@odata.bind" = "/accounts(" & Text.From(account[accountid]) & ")",
     								#"pricelevelid@odata.bind" = "/pricelevels(" & Text.From(pricelevel[pricelevelid]) & ")",
     								billto_city = Record.FieldOrDefault(Source, "billtocity"),
     								billto_stateorprovince = Record.FieldOrDefault(Source, "billtostateorprovince"),
     								billto_country = Record.FieldOrDefault(Source, "billtocountry"),
     								billto_postalcode = Record.FieldOrDefault(Source, "billtozip"),
     								shipto_city = Record.FieldOrDefault(Source, "shiptocity"),
     								shipto_stateorprovince = Record.FieldOrDefault(Source, "shiptostateorprovince"),
     								shipto_country = Record.FieldOrDefault(Source, "shiptocountry"),
     								shipto_postalcode = Record.FieldOrDefault(Source, "shiptozip")
     							]
     						), each [Value] <> null
     					)
     				),
    
     orderlines = List.Transform(orderProducts, each
     					Record.FromTable
     					(
     						Table.SelectRows
     						(
     							Record.ToTable
     							(
     								[
     									ispriceoverridden = true,
     									#"productid@odata.bind" = "/products(" & IOM.MapRecord(IOM.MappingTables[product], [sku = Record.FieldOrDefault(_, "sku")])[productid] & ")",
     									#"uomid@odata.bind" = "/uoms(" & IOM.MapRecord(IOM.MappingTables[uom], [unit = Record.FieldOrDefault(_, "unit")])[uomid] & ")",
     									quantity = [quantity]
     								]
     							), each [Value] <> null
     						)
     					)
     				),
    
     salesorder = Record.AddField(orderheader, "order_details", orderlines)
    
     in Text.FromBinary(Json.FromValue(salesorder));
    
    
  12. For Transformation Source Type, enter JsonPayload.

  13. Select Save.

  14. Create a JSON file, paste in the following code, and then save it.

    {
      "ordernumber": "LabOrder001",
      "shiptocity": "BELLEVUE",
      "shiptostateorprovince": "WA",
      "shiptocountry": "US",
      "shiptozip": "98007",
      "billtocity": "BELLEVUE",
      "billtostateorprovince": "WA",
      "billtocountry": "US",
      "billtozip": "98007",
      "orderdetails": [
    {
      "sku": "883988211855",
      "unit": "each",
      "quantity": 11
    }
      ]
    } 
    
  15. Next to the Sample Data field, select Choose File and then upload the JSON file that you created.

  16. Select Save & close.

Add a provider definition transformation to a solution

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

  1. Go to Power Apps maker portal and go to the newly created LabProviders solution.
  2. Select Add existing > Provider Definition Transformation.
  3. Select Lab Order to Dataverse Order, and then select Add to add it to the solution.

Create a provider message handler

To create a provider message handler, follow these steps:

  1. Go to Power Apps maker portal, go to Solutions, and then open the Default Solution.

  2. Select New.

  3. Select Cloud Flow and then name it Lab Order Intake Message Request Handler.

  4. Select the trigger type as Outlook.com – When a new email arrives (V2), and then sign in with your outlook.com account credentials.

  5. For Folder, select Inbox.

  6. For To, select Recipient email addresses separated by semicolons.

  7. For CC, select CC recipient email addresses separated by semicolons.

  8. For To or CC, select To or CC recipient email addresses separated by semicolons.

  9. For From, select Sender email addresses separated by semicolons.

  10. For Include Attachments, select Yes.

  11. For Subject Filter, select LabOrderIntakeOrder.

  12. For Importance, select Any.

  13. For Only with Attachments, select Yes.

    Screenshot of the Microsoft Outlook trigger page.)

  14. Select New step and then add parse json.

  15. For Content, paste in the following code:

    {
    "ProviderId": "00000000-0000-0000-0000-000000000000"
    }
    
  16. Select Generate from sample and then paste in the following sample schema code:

    {
      "type": "object",
      "properties": {
        "ProviderID": {
          "type": "string"
        }
      }
    }
    
  17. Select Done.

  18. Select the ellipsis (...) and then select Rename.

  19. Rename the action IOM System Properties.

  20. Select Save.

    Screenshot of the IOM System Properties action page)

  21. Select New step, add a Parse JSON action, and then rename it to Initialize Provider Variables.

  22. For Content, paste in the following code:

    {
      "SourceObjectName": "IOMLab Order",
      "DestinationObjectName": "Dataverse Order"
    }
    
  23. Select Save.

  24. Select New step, add an Initialize variable action, and then rename it to Initialize Processing Execution Result.

  25. For Name, enter ExecutionResult.

  26. For Type, select Boolean.

  27. For Value, select true.

  28. Select Save.

    Screenshot of the Initialize Processing Execution Result page.

  29. Select New step, add scope, and then rename it to Try.

  30. In the Try scope, select Add an action.

  31. Add perform an unbound action from the Dataverse connector and then rename it to Acknowledge the Provider Message.

  32. For Action Name, enter msdyn_CreateProviderMessageRequestExecution.

  33. For PowerAutomateWorkflowId, enter workflow()['tags']['xrmWorkflowId'] as an expression.

  34. For PowerAutomateRunId, enter workflow()['run']?['name'] as an expression.

  35. For ProviderExternalRequestId, enter guid() as an expression.

  36. Select Save.

    Screenshot of the Acknowledge the Provider Message in IOM page.

  37. Select Add an action and then add an Apply to each control.

  38. For Select an output from previous steps, select Attachments.

  39. Select Add an action within the Apply to each loop, add Run a child flow from the Flow connector, and then rename it Transform Message with Power Query Online.

  40. For Provider Id, select the ProviderId variable.

  41. For Source Object Name, select the SourceObjectName variable.

  42. For Destination Object Name, select the DestinationObjectName variable.

  43. For Payload, enter decodeBase64(items('Apply_to_each')?['ContentBytes']) as an expression.

  44. Select Save.

    Screenshot of the Transform Message with Power Query Online page.

  45. After the transformation step, select Add an action, add Run a child flow from the Flow connector, and then rename it Create Order.

  46. For Child Flow, enter Sales Order Creation.

  47. For Payload, enter string(json(outputs('Transform_Message_with_Power_Query_Online')?['Body']?['result'])?[0][0]) as an expression.

  48. Select Save.

    Screenshot of the Create Order page.

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

  50. Select New step, add a scope, and then rename it Catch.

  51. In the Catch scope, select the ellipsis (...) and then select Configure run after.

  52. Select the has failed and has timed out checkboxes and then select Done.

    Screenshot of the Configure run after page.

  53. In the Catch scope, select Add an action, add a Set variable action, and then rename it Set the execution result to failed.

  54. For Name, enter ExecutionResult.

  55. For Value, select False.

  56. Select Save.

    Screenshot of the Set variable action page.

  57. Collapse the Catch scope by selecting its title bar.

  58. Select New step, add a scope, and then rename it to Finally.

  59. In the Finally scope, select the ellipsis (...) and then select Configure run after.

  60. Select the is successful, has failed, is skipped, and the has timed out checkboxes. Select Done.

    Screenshot of the Finally should run after scope page.

  61. In the Finally scope, select Add an action, add Perform an unbound action, and then rename it to Save Provider message request execution result.

  62. For Action Name, enter "msdyn_UpdateProviderMessageRequestStatus".

  63. For ProviderMessageRequestExecutionId, enter @outputs('Acknowledge_the_Provider_Message')?["body/ProviderMessageRequestExecutionId'].

  64. Select Save.

    Screenshot of the Save provider message request execution result.

Add a provider definition logic definition to the provider definition

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

  1. In your Intelligent Order Management application, go to Providers > Catalog.
  2. Select the newly created LabOrderIntakeProvider.
  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 Lab Order Intake Message Request Handler.
  7. For Logical Name, enter msdyn_LabOrderIntakeMessageRequestHandler.
  8. For Provider Definition, enter LabOrderIntakeProvider.
  9. For Logic Type, enter Provide Message Handler.
  10. For Workflow Name, enter Lab Order Intake Message Request Handler.
  11. For Timeout Minutes, enter 2.
  12. For Max Retry Attempts, enter 3.
  13. For Description, enter Lab Order Intake Message Request Handler.
  14. Select Save. This step will generate a JSON representation of the message handler cloud flow and will fill in the Client Data field.
  15. Select Save & Close.
  16. Select Connections. The Microsoft Dataverse and Outlook.com connection reference definitions should be listed.

Note

If connection reference definitions other than Microsoft Dataverse and Outlook.com display, it means that you are using more than one Dataverse connection reference in your order intake message handler flow. To fix this issue, go to your flow and ensure that all Dataverse actions are using the same connection reference.

Add a provider definition logic definition to the LabProviders solution

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

  1. Select Add existing > Provider Definition Logic Definition.
  2. Select Lab Order Intake Message Request Handler and then select Add to add it to the solution.

Add a provider definition connection reference to the LabProviders solution

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

  1. Go to Power Apps maker portal and go to the newly created LabProviders solution.
  2. Select Add existing > Provider Definition Connection Reference.
  3. Select the Microsoft Dataverse and Outlook.com connection reference definitions and then select Add to add them to the solution.