# Tracking Data Changes in Power Automate Using Audit Logs

## **Why Enable Auditing?**

Auditing in Microsoft Dataverse helps in maintaining a log of all data changes. This is important for:

* Maintaining a history of data modifications
    
* Meeting compliance and regulatory standards
    
* Troubleshooting data integrity issues
    

## **Enable Auditing in Dataverse**

**System Settings:**

* Navigate to *Power Apps admin centre (*[https://admin.powerplatform.microsoft.com/home](https://admin.powerplatform.microsoft.com/home)*) &gt; choose your environment &gt; Settings &gt; Audit Settings*
    
* Under the *Auditing* tab, ensure start auditing is enabled
    
* ![Enable Auditing in System Settings](https://wonderful-pond-0a78e0200.5.azurestaticapps.net/api/data/v9.0/msdyn_knowledgearticleimages(01df39a9-b93c-f011-877b-000d3af2afe6)/msdyn_blobfile/$value align="left")
    

**Enable Table-Level Auditing:**

* Select the table (e.g., `Account`)
    
* Enable “Audit changes to its data” in the table properties (Advanced Options)
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1756984739321/b7f4a09a-6e63-41cd-a2ed-3c8c382581e2.png align="center")
    

**Enable Column-Level Auditing:**

* Select individual columns (e.g., `Telephone1`)
    

Enable the “Enable Auditing” option

![](https://wonderful-pond-0a78e0200.5.azurestaticapps.net/api/data/v9.0/msdyn_knowledgearticleimages(da78416c-1f84-f011-b4cc-000d3af2afe6)/msdyn_blobfile/$value align="left")

## **Create Power Automate Flow to Retrieve Audit Data**

1. **Trigger:** Use `When a row is modified` for the table you are tracking.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1756984960522/8b7c6f12-6919-4def-bd2c-a53353a5ff63.png align="center")
    
2. **List Audit Records:**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1756985020241/9129a394-96ec-4972-a83b-bf22b18543f6.png align="center")
    
    Query Expression:
    
    ```powershell
    objecttypecode eq 'account' and _objectid_value eq 'triggerOutputs()?['body/accountid']'
    ```
    
    * Add a `List rows` Dataverse action
        
    * Use this OData filter query:
        
    * Sort by `createdon desc`
        
3. **Parse Audit Data:**
    
    1. Use a `Parse JSON` action:
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1756985085859/99f779ed-b2b5-4f0b-8c3b-2e3639952b41.png align="center")
        
        Content expression:
        
        ```powershell
        first(outputs('List_rows')?['body']?['value'])?['changedata']
        ```
        
        Response:
        
        ```json
        {
          "OldValue": {
            "field1": "Old Value 1"
          },
          "NewValue": {
            "field1": "New Value 2"
          }
        }
        ```
        
4. **Extract Old and New Values:**
    
    1. Use a `Compose` action with below expression:
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1756985228206/ee6fe8e7-5d99-4ff3-abe6-673722505511.png align="center")
        
        ```scss
        outputs('Compose')?['changedAttributes'][0]['OldValue']
        ```
        
        ```scss
        outputs('Compose')?['changedAttributes'][0]['NewValue']
        ```
        

## **Conclusion**

Audit logs provide a transparent trail of changes made to data within Dataverse. When combined with Power Automate, they empower users to create intelligent flows that not only respond to changes but also reference historical data. This setup is particularly valuable for quality control, approvals, and governance automation.

We hope this guide helps you understand how to retrieve old and updated data using audit logs in Power Automate. Feel free to leave a comment or reach out for further assistance.
