How to Add a Dataverse Action or Function to Your Power Apps Code App (Step-by-Step)
How to Add a Dataverse Action or Function to Your Power Apps Code App
If you're building a Power Apps code app and need to interact with Microsoft Dataverse, knowing how to discover and integrate Dataverse operations — including actions and functions — is essential. This step-by-step guide walks you through the entire process, from finding the right Dataverse operation to wiring it up inside your code app.
Whether you're automating business logic, triggering workflows, or retrieving structured data, Dataverse actions and functions give your app the power it needs. Let's dive in.
What Are Dataverse Actions and Functions?
Before we get started, it helps to understand the difference between the two operation types:
- Actions — Operations that can make changes to data (create, update, delete, or trigger business logic). They use HTTP
POSTrequests. - Functions — Read-only operations that retrieve data without modifying it. They use HTTP
GETrequests.
Both types are exposed through the Dataverse Web API and can be called directly from your Power Apps code app using the Power Platform development tooling.
Prerequisites
Before adding a Dataverse action or function to your code app, make sure you have the following in place:
- A Power Apps environment with Dataverse enabled
- An existing code app project (or permission to create one)
- Appropriate security roles to call the Dataverse operations you need
- Basic familiarity with the Dataverse Web API
Need help setting up your environment? Our team offers Dynamics 365 and Dataverse implementation services to get you started on the right foot.
Step 1: Discover Available Dataverse Operations
The first step is identifying which actions or functions are available in your Dataverse environment.
Using the Dataverse Web API Metadata
You can query the Dataverse Web API metadata endpoint to list all available actions and functions:
- Navigate to
https://<your-org>.crm.dynamics.com/api/data/v9.2/$metadatain your browser - Search for
ActionorFunctionelements within the metadata XML - Note the name, parameters, and return types for the operation you need
Using the Power Apps Maker Portal
- Open make.powerapps.com
- Navigate to your environment's Dataverse tables and customizations
- Review any custom actions registered against tables or globally
Step 2: Add the Dataverse Operation to Your Code App
Once you've identified the action or function you want to use, follow these steps to integrate it into your code app.
2a. Open Your Code App Project
- Open your code app project in your preferred IDE (Visual Studio Code is recommended)
- Ensure the Power Platform CLI tools are installed and configured
2b. Use the pac Command to Add the Operation
The Power Platform CLI (pac) provides tooling to scaffold and add Dataverse operations directly into your code app. Run the appropriate pac command for your operation type:
- For actions: Use
pac power-fxor the relevant connector/API reference command to register the action call - For functions: Reference the function via the Dataverse Web API URL pattern in your app logic
2c. Configure Parameters and Authentication
- Map the required input parameters for the action or function
- Ensure your app's connection is authenticated against the correct Dataverse environment
- Handle response objects and error states gracefully in your code
Step 3: Test Your Integration
Always test your Dataverse operation thoroughly before deploying to production:
- Run your code app in development/test mode
- Trigger the action or function and verify the response matches expectations
- Check the Dataverse audit logs to confirm the operation executed correctly
- Test edge cases: missing parameters, insufficient permissions, and network errors
Looking to automate follow-up steps after your Dataverse action runs? Consider combining your code app with Power Automate flows for end-to-end process automation.
Common Issues and Troubleshooting
Operation Not Found
If your action or function doesn't appear as expected, verify that it has been published in your Dataverse environment and that your security role includes the necessary privileges.
Authentication Errors
Ensure your code app connection references the correct environment URL and that the user or service principal has the required Dataverse roles assigned.
Parameter Mismatch
Double-check the parameter names and types against the Dataverse metadata. Case sensitivity and data type mismatches are common causes of failures when calling Dataverse actions.
Best Practices
- Always use functions (not actions) for read-only operations to avoid unintended data changes
- Implement proper error handling around every Dataverse operation call
- Use environment variables to manage your Dataverse endpoint URLs across dev, test, and production
- Document your custom actions so other developers on your team can discover and reuse them
- Review Microsoft's official Power Apps documentation regularly for updates to the Dataverse Web API
Take Your Power Apps Development Further
Integrating Dataverse actions and functions into your code apps is just one piece of building powerful, enterprise-grade solutions on the Power Platform. At CRMONCE, we help businesses design, develop, and deploy tailored Power Platform solutions that drive real results.
Explore how we can support your team:
- Power Platform Development Services — Custom code apps, components, and integrations
- Dynamics 365 Implementation — End-to-end Dataverse and D365 deployments
- Power Automate Solutions — Automate workflows connected to your Dataverse data
- Professional Training — Upskill your team on Power Apps and Dataverse development
- Consulting Services — Strategic guidance from certified Power Platform experts
Ready to build smarter Power Apps? Whether you need hands-on development support or expert consulting, our team is here to help. Contact CRMONCE today and let's talk about your project.