Parsing the flow data for debugging

Data for any run of a flow can be retrieved, parsed, and used for debugging purposes via the workflow() function. The data includes properties that identify the flow which can be used to identify the run and allow you to do things like a link to that particular run or send rich notifications when a flow runs.

To do this, there are a few steps involved that could be part of any flow.

    1. Add a Compose step and set its input to workflow().
      Screenshot of Power Automate workflow compose
    2. Then add a ParseJSON step and set its content to the Output of the previous step. We will set the Schema field empty to an empty object, {} for now as we will need to retrieve it first.
      Screenshot of Power Automate workflow Parse JSON
    3. To retrieve the schema of the workflow JSON, we will first need to save and run the flow.
    4. Next, view the output of the run and copy the resulting JSON.
      Screenshot of Power Automate workflow Parse JSON outputs for debugging
    5. Return to the flow and select Generate from Sample in the ParseJSON step. Paste the copied output and click done.
      Screenshot of Power Automate workflow Insert a sample JSON Payload window
    6. Doing this will generate a schema from the JSON output which looks like this. Tip: This can be done for any JSON response from an endpoint when you do not have the schema readily available.
      Screenshot of Power Automate Parse JSON outputs
    7.  From here you can use the data about the current run in the subsequent steps. In this example, the data is initialised as an object variable.
      Screenshot of Power Automate workflow Initialise variable details