Business events and Microsoft Power Automate

Important

Dynamics 365 for Finance and Operations is now being licensed as Dynamics 365 Finance and Dynamics 365 Supply Chain Management. For more information about these licensing changes, see Dynamics 365 Licensing Update.

This topic provides steps detailing how to configure and consume a business event from a Power Automate endpoint.

This topic shows how to perform the following tasks:

  • Create a new Power Automate.
  • Trigger a business event.

Create a new Power Automate

  1. Sign in to Power Automate portal.

  2. Select an existing environment where you have the permissions needed to create a Power Automate resource. The default environment is open to all companies.

  3. Select New > Create from blank.

  4. Search for Dynamics 365 for Finance and Operations and select the connector.

  5. You will notice a trigger named When a Business Event occurs. Select this trigger.

  6. Select your environment instance, category, event name, and legal entity.

    Tip

    Take advantage of the auto-complete that Power Automate provides by entering only part of the environment instance URL or part of the event name.

    Microsoft Power Automate buisness event trigger
  7. Select the New Step button to add a new action.

  8. Search for the Parse JSON data operation. This step is needed to parse the message with the schema of the data contract.

    Parse JSON action
  9. Select the content field of Parse Json action, then the Body output from the previous step should appear as an option. Select Body.

    Parse JSON input
  10. Enter the schema of the contract. Because the app provides only a sample payload you can use the Power Automate capability to generate a schema from a payload. Select an event in the catalog (for example, Customer Payment) and select the Download schema link. This will download a text file. Open the text file and copy the content.

    Event payload
  11. Go Back to Power Automate and select the Use sample payload to generate schema link. Paste your text file content and select Done.

    Parse JSON schema input
  12. Depending on the quality of your sample payload, your generator will not be able to distinguish between an integer and a real number. This is true if the real number is provided as a whole number in the sample payload. Review your generated schema and check if you need to change an “integer” into “number”. (In JSON, a “number” data type means real number).

    JSON data types
  13. Choose another final action to consume the business event content. For instance, you can send an email (or post a text message to Teams) to notify the customer about payment details. Search for the Send email action, then sign in to your Office 365 account.

  14. Fill in the message with the required fields.

Microsoft Power Automate send email action
  1. Save Power Automate.

Trigger a Business Event

Power Automate can configure the application automatically for you. After you save your Power Automate it creates an endpoint, then it activates the business event for you. There is no remaining configuration step apart from verifying that the endpoint has been correctly configured before triggering an event.

  1. Sign in to the client.

  2. Go to System Administration > Setup > Business Events.

  3. Select Endpoints.

  4. Verify that a new endpoint has been created with a GUID appended in the name.

    Microsoft Power Automate buiness event GUID
  5. If you check the Active events tab you can also verify that “Payment Posted” is activated for legal entity GBSI.

    Active business events
  6. The final step is to trigger the business event of a posted customer payment and check whether the Power Automate runs and you receive an email with customer payment details.

Troubleshooting a Power Automate

Here are some troubleshooting suggestions:

  • Power Automate provides a full history of runs to help determine what might be wrong with a failing flow.
  • When reviewing a failed run, carefully review the inputs and outputs of trigger and action blocks.
  • After changes have been made to Power Automate, go to the latest run or a particular run, and Resubmit the inputs to run the Power Automate again.