July 10th, 2025
0 reactions

Use Agent to Update Dataverse Table Content

Introduction

Some time ago, I watched a demo of an AI agent updating a row in a table. The scenario was simple but effectively demonstrated the tool’s capabilities and potential benefits for users. This made me wonder whether the same could be achieved using Microsoft Power Platforms. This article explores how to build an agent in Microsoft Copilot Studio to update information in a Dataverse table.

Problem Statement

The Dataverse table Inventory stores current stock levels of materials, including stock thresholds and units of measure. The agent should be able to:

  • Answer questions about stock levels
  • Determine if a material needs to be replenished
  • Update stock levels using natural language commands

Example User Queries:

  • What is the stock of coffee?
  • How much paper towel do I have in stock?
  • Do I need to buy more soap?
  • Add 2 more units of sugar.

In summary, the agent must be capable of answering stock-related queries, assessing whether additional purchases are needed, and updating stock levels for each material.

Solution

The solution is an agent using the new Copilot Studio feature generative orchestration to determine the best actions, knowledge, and topics to answer user queries or respond event triggers. The agent is composed of a knowledge source, a topic, and an AI prompt.

The Inventory knowledge source is responsible for connecting to the Dataverse table that contains the inventory data and answering questions about the inventory. Since the column names are self-explanatory, it is not necessary to add any synonyms or glossaries to the knowledge definition.

The topic Update Inventory will be triggered when the user utters some update action, like “update inventory”, “add units”, etc. In the topic, the prompt action Material information from Dataverse table will extract relevant inventory information from the user prompt, like material name and quantity to be added, and retrieve the actual record for the material from the table.

The next action is Update inventory table which will update the Dataverse table Inventory based on the inventory information extract by the prompt node.

The prompt action is the most critical element of the solution. Prompt actions are a very powerful tool. You can invoke Large Language Models (LLM) to execute all sort of actions. In this case, the prompt action is being used to retrieve critical information from the inventory table, like the Row ID, based on the user’s prompt.

Solution breakdown

Here is the implementation detail for every part of the solution.

Agent attributes

Create an agent with the following information:

Name: Inventory Control
Description: An agent designed to manage the Inventory Dataverse table, providing functionalities such as listing materials with stock below the threshold and checking stock positions for specific materials.
Instructions:
- Manage the Inventory Dataverse table.
- Provide functionalities to list materials with stock below the threshold.
- Check stock positions for specific materials.
- Ensure accurate and up-to-date information.
- Respond promptly and efficiently to user queries.
- Avoid providing any financial, legal, or health advice.
- Maintain a professional and helpful tone.

Those descriptions will be used by the orchestrator to decide which knowledge, topic or action should be triggered. It is not just for documentation purpose, but it is part of the agent operation.

Knowledge

Knowledge sources are components the agents use to take action and/or provide information based on data provided by the user. It could be documents or database tables. The following knowledge source were created to access the data in the Inventory table at Dataverse.

Name: Inventory
Description: This knowledge source answers questions found in the following Dataverse tables: Inventory 

Inventory Dataverse table knowledge

Topics

The new topic is to manage the update flow. During the update, it is necessary to retrieve the Row ID and use the action to update Dataverse table.

Name: Update Inventory 
Trigger by agent, based on the following description on what the topic does: This tool can handle queries like these: update inventory, inventory update, change stock levels, modify inventory, adjust product quantities, add units

You should be very descriptive here. This is not just for documentation purposes; the more precisely you describe the topic, the better the orchestrator will be at triggering it in the right situations.

Prompt action

The AI prompt Material information from Dataverse table is the key component. The prompt will extract relevant information from the user prompt and get the actual row information for the material. The AI prompt has the following attributes:

Extract the material name, quantity added and unit of measure from the text [Add to the inventory]. Use the material name to get Row ID from [Inventory.Material Name]. 
Answer using JSON format, using the following fields:
{
    "Material_Name": [Inventory.Material Name], 
    "Quantity_Added": quantity added,
    "Quantity_in_Stock": [Inventory.Quantity in Stock], 
    "Unit_of_Measure": [Inventory.Unit of Measure], 
    "Row_Id": row id from Inventory table
}
You also need to add the quantity extracted from the text to the actual quantity in stock.
The unit of measure needs to be formatted as 1 for Unit and 2 for Box.

The expected output for this prompt is a JSON structure with relevant information to update the table in the next action.

{
  "Material_Name": "Sugar",
  "Quantity_Added": 10,
  "Quantity_in_Stock": 28,
  "Unit_of_Measure": 1,
  "Row_Id": "485fa596-d4ab-471c-8452-30729a25f66d"
}

Prompt to return inventory information from Dataverse table

Inventory table

The Inventory table resides in the Dataverse. It is a very simple table, created just for the purpose of the demo. Here is an example of the content:

Material Name Quantity Unit of Measure Stock Threshold
Coffee 50 Unit 10
Coffee filter 100 Unit 20
Paper tower 200 Unit 50
Soap 2 Box 5
Sugar 20 Unit 10

Exercising the agent

To see the agent in action, just prompt some questions using the test panel. Here are some examples of questions that the agent should be able to answer:

  • How much sugar do I have in stock?
  • Should I need to buy more sugar?
  • Add 20 more units of sugar to the stock.
  • Do I have enough sugar in stock? How much sugar do I have in stock?

Testing the Inventory Control agent

Conclusion

The goal of this simple agent is to demonstrate a solution that enables a Microsoft Copilot Studio agent to update a table. You can enhance the agent by adding more capabilities, such as updating the material description, modifying the stock threshold, decreasing stock levels, or even generating a list of materials that need to be purchased when stock levels fall below the threshold.

Author