How to Run a Flow on a Selected Record from a Model-Driven App and Pass Custom Parameters
Model-driven apps in Dynamics 365 offer a robust way to build applications that rely on your data model. One powerful feature that can greatly enhance your app’s functionality is the ability to run a Power Automate flow directly on a selected record within the app. This is particularly useful for automating tasks or processes that require custom parameters based on the selected record.
Watch the video to learn practically or read the article.
In this blog post, we’ll walk through the steps to set up and run a flow on a selected record from a model-driven app, passing custom parameters along the way.
Step 1: Create the Power Automate Flow
- Sign in to Power Automate: Start by logging into Power Automate at flow.microsoft.com.
- Create a New Flow:
- Click on “Create” from the left-hand menu and select “Instant cloud flow.”
- Name your flow, e.g., “Run on Selected Record,” and choose the “When a record is selected” trigger from Dataverse.
- Configure the Trigger:
- Select the environment and the table (entity) for which this flow should run.
- Add the required inputs that you want to pass as custom parameters. For example, you might want to pass a string, a number, or even a lookup to another entity.
- Add Actions:
- Based on your needs, add actions that should be performed when the flow is triggered. For instance, you could send an email, create a new record, or update existing records.
- Make sure to use the custom parameters you’ve added as inputs in these actions.
- Save and Test Your Flow:
- Save your flow and test it by manually running it from within Power Automate to ensure everything works as expected.
Step 2: Integrate the Flow into Your Model-Driven App
- Navigate to Your Model-Driven App:
- Open your model-driven app in the Power Apps maker portal.
- Select a Record:
- Navigate to the view or form where your table (entity) records are displayed.
- Select a record you want to run the flow on.
- Run the Flow:
- Click on the “Flow” button in the command bar (this might be under the “Automate” menu, depending on your setup).
- Choose your flow from the list. This will open a pane where you can input the custom parameters you’ve configured.
- Fill in the required parameters and click “Run flow.”
- Verify the Flow Execution:
- Once the flow is executed, verify that it has performed the intended actions. You can check the flow’s run history in Power Automate to see the details.
Step 3: Handling Custom Parameters
Passing custom parameters is a powerful feature that allows you to tailor the flow’s behavior based on the selected record. Here are some tips for handling these parameters:
- Dynamic Content: Use the dynamic content feature in Power Automate to map the selected record’s fields to the custom parameters.
- Expressions: If you need to manipulate the data before passing it as a parameter, use expressions within Power Automate.
- Validation: Ensure that your flow includes validation steps to handle cases where parameters might be missing or incorrectly formatted.
Conclusion
Running flows on selected records in a model-driven app with custom parameters opens up a world of possibilities for automating business processes and enhancing user productivity. By following the steps outlined in this guide, you can integrate powerful automation into your model-driven apps, making them more dynamic and responsive to user actions.