Create intake provider

This topic describes the steps required to create an intake provider in Microsoft Dynamics 365 Intelligent Order Management.

Create new provider definition

To create new provider definition, follow these steps.

  1. Go to Providers > Catalog.
  2. Select New Provider Definition.
  3. For Display Name, enter "IOMLabOrderIntakeProvider".
  4. For Logical Name, enter "msdyn_IOMLabOrderIntakeProvider".
  5. For Logo, select "IOMLab.png".
  6. For Service Type, enter "Order intake".
  7. For Description, enter "IOM lab order intake provider".
  8. Select Save & close.

Add provider definition to solution

To add a provider definition to a 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 IOMLabOrderIntakeProvider, and then select Add to add it to the solution.

Add 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 IOMLabOrderIntakeProvider.
  3. Select Edit on the menu bar.
  4. Select the Transformations tab.
  5. Select + New IOM Provider Definition Transformation.
  6. For Display Name, enter "IOMLab Order to Dataverse Order".
  7. For Logical Name, enter "msdyn_IOMLabOrderIntake_Order".
  8. For Provider Definition, enter or select IOMLabOrderIntakeProvider.
  9. For Source Object Name, enter "IOMLabOrderIntakeProvider".
  10. For Destination Object Name, enter "Dataverse Order".
  11. For Transformation, paste in the following M query code:
shared ImportMappingKey = [
    account = {
			[
				ExternalRecordKey = [ProviderName = "IOMLabOrderIntakeProvider"],
				SelectedFields = {"accountid"}
			]
    },
		pricelevel = {
			[
				ExternalRecordKey = [ProviderName = "IOMLabOrderIntakeProvider"],
				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 = "IOMLabOrderIntakeProvider"]),
	pricelevel = IOM.MapRecord(IOM.MappingTables[pricelevel], [ProviderName = "IOMLabOrderIntakeProvider"]),
			
	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],
										shipto_name = Record.FieldOrDefault(orderheader, "shipto_name"),
										shipto_contactname = Record.FieldOrDefault(orderheader, "shipto_contactname"),
										shipto_line1 = Record.FieldOrDefault(orderheader, "shipto_line1"),
										shipto_line2 = Record.FieldOrDefault(orderheader, "shipto_line2"),
										shipto_line3 = Record.FieldOrDefault(orderheader, "shipto_line3"),
										shipto_city = Record.FieldOrDefault(orderheader, "shipto_city"),
										shipto_stateorprovince = Record.FieldOrDefault(orderheader, "shipto_stateorprovince"),
										shipto_country = Record.FieldOrDefault(orderheader, "shipto_country"),
										shipto_postalcode = Record.FieldOrDefault(orderheader, "shipto_postalcode"),
										shipto_telephone = Record.FieldOrDefault(orderheader, "shipto_telephone")
									]
								), each [Value] <> null
							)
						)
					),

	salesorder = Record.AddField(orderheader, "order_details", orderlines)
in Text.FromBinary(Json.FromValue(salesorder));
  1. For Transformation Source Type, enter "JsonPayload".
  2. Select Save.
  3. Create a JSON file, paste in the following code, and save it.
{
  "ordernumber": "IOMLabOrder001",
  "shiptocity": "BELLEVUE",
  "shiptostateorprovince": "WA",
  "shiptocountry": "US",
  "shiptozip": "98007",
  "billtocity": "BELLEVUE",
  "billtostateorprovince": "WA",
  "billtocountry": "US",
  "billtozip": "98007",
  "orderdetails": [
    {
      "sku": "883988211855",
      "unit": "each",
      "quantity": 11
    }
  ]
} 

  1. Next to the Sample Data field, select Choose File and upload the JSON file you created.
  2. Select Save & close.

Add provider definition transformation to solution

To add a provider definition transformation to a 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 Transformation.
  3. Select IOMLab Order to Dataverse Order, and then select Add to add it to the solution.

Create provider message handler

To create a provider message handler, follow these steps.

  1. Go to the Power App Maker portal, navigate to Solutions, and open the Default Solution.

  2. Select New.

  3. Select Cloud Flow, and then name it "IOM 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 IOMLabOrderIntakeOrder.

  12. For Importance, select Any.

  13. For Only with Attachment, select Yes.

    Outlook trigger)

  14. Select New step and add "Parse JSON".

  15. For Content, paste in the following code:

    {
    "ProviderId": "00000000-0000-0000-0000-000000000000"
    }
    
  16. Directly 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.

    System properties action)

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

  22. For Content, paste in the following code:

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

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

  25. For Name, enter "ExecutionResult".

  26. For Type, select Boolean.

  27. For Value, select true.

  28. Select Save.

    Initialize processing execution result

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

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

  31. Add "perform an unbound action" from the Dataverse connector and rename it "Acknowledge the Provider Message in IOM".

  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.

    Acknowledge provider message

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

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

    Apply to each control

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

  40. Select the child flow IOM Provider Transformer.

  41. For Provider Id, select the ProviderId variable.

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

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

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

  45. Select Save.

    Transform message with Power Query

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

  47. For Child Flow, enter "IOM Sales Order Creation".

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

  49. Select Save.

    Create Order

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

  51. Select New step, add a scope and rename it "Catch".

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

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

    Configure run after

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

  55. For Name, enter "Executionresult".

  56. For Value, select False.

  57. Select Save.

    Set variable action

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

  59. Select New step, add a scope and rename it "Finally".

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

  61. Select the is successful, has failed, is skipped, and has timed out checkboxes, and then select Done.

    Configure run after (Finally scope)

  62. In the Finally scope, select Add an action, add a Perform an unbound action action and rename it "Save Provider message request execution result".

  63. For Action Name, enter "msdyn_UpdateProviderMessageRequestStatus".

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

  65. Select Save.

    Save provider message request execution result

Add 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 IOMLabOrderIntakeProvider.
  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 Order Intake Message Request Handler".
  7. For Logical Name, enter "msdyn_LabOrderIntakeMessageRequestHandler".
  8. For Provider Definition, enter "IOMLabOrderIntakeProvider".
  9. For Logic Type, enter "Provide Message Handler".
  10. For Workflow Name, enter "IOM Lab Order Intake Message Request Handler".
  11. For Timeout Minutes, enter "2".
  12. For Max Retry Attempts, enter "3".
  13. For Description, enter "IOM Lab Order Intake Message Request Handler".
  14. Select Save. This generates a JSON representation of the message handler cloud flow and fills in the Client Data field.
  15. Select Save & close.
  16. Select Connections. You should see both the Microsoft Dataverse and Outlook.com connection reference definitions listed.

Note

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

Add provider definition logic definition to IOMLabProviders solution

To add a provider definition logic definition to the IOMLabProviders 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 Logic Definition.
  3. Select IOM Lab Order Intake Message Request Handler and then select Add to add it to the solution.

Add provider definition connection reference to IOMLabProviders solution

To add a provider definition connection reference to the IOMLabProviders 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 Connection Reference.
  3. Select the Microsoft Dataverse and Outlook.com connection reference definitions and then select Add to add them to the solution.

Next quick start lab step: Create fulfillment provider.