top of page
  • Writer's pictureAlan Campbell

Business Central & Power Automate: Harnessing Environment Variables

Navigating the Power Platform universe requires a deep understanding of Application Lifecycle Management (ALM) for developers who aim to seamlessly integrate Power Automate flows within the diverse ecosystems of Microsoft Business Central. The path from development through sandbox testing to the final production stage highlights the crucial role of a meticulously managed ALM process. Central to this journey is the adept use of environment variables in Power Automate flows, a technique that stands out for its ability to ensure application consistency, scalability, and integrity across various development phases.


Use Power Platform environment variables when creating power automate flows in order to maximize ALM for Power Platform developers.
Power Platform Environment Variables

This blog post is crafted as a comprehensive guide aimed at unraveling the complexities of leveraging environment variables effectively. Designed for both seasoned developers and IT professionals, it addresses the challenges encountered when managing Power Automate apps across different Power Platform environments—development, sandbox, and production—alongside corresponding Business Central stages.


Beginning with the basics of solution creation in the development environment, we will guide you through the nuanced steps of embedding environment variables into your Power Automate lifecycle management. The journey encompasses the addition of key variables, such as the Business Central environment name and company ID, and extends to the creation of automated flows that utilize these variables to boost operational efficiency. Our goal is to furnish you with the essential skills to fine-tune your Power Platform projects.

Throughout this exploration, we aim to provide clarity on both the 'how' and the 'why' behind each procedure. By the conclusion of this guide, you will possess a solid foundation to confidently export and import your solutions across varying Power Platform environments, all while maintaining ease and assurance.


Join us as we delve into the intricacies of Power Automate, unlocking the full potential of environment variables to streamline your ALM endeavors.


Building Your Solution


Start by creating a solution in your development environment. In your power automate development environment go to the panel on the left and click on Solutions. Then click on New solutions in the header to create your solution.

Start by creating a solution before using environment variables. Environmental variables must reside in a Power Platform solution.
Solutions

Adding Environment Variables


Add two environment variables to the solution. First the Business Central environment name variable and then the Business Central company id variable. To create the first variable click on + New in the header, select More and click on Environment variable.


Click on Environment variable to create a new variable in power automate.
Add an Environment Variable

Enter the Business Central environment name in the Display name field followed by the Description and Default Value for the Business Central environment.


Enter the business central environment name when creating the power automate environment variable.
Business Central Environment Name

Create another environment variable. This time you will create the Business Central company id variable. Note that you are entering the id number and not the name of the company.


Enter the business central company id when creating environment variables.
Business Central Company Id

Creating an Automated Flow


Click on + New in the header followed by Automation, Cloud flow, and Automated. Give the flow a name, enter dynamics 365 business central in the search box, and then select When a record is created (V3).


Create a power automate flow that will use the environment variables.
Create a Power Automate Flow


In the Environment field click on Enter custom value. In the Dynamics content window click on the environment variable you created earlier. Do the same for the Company field. Fill in the API category and Table name as you normally do. Complete the flow and save. The flow will now use your new Business Central environment name and company id variables.


In the power automate dynamic content window select the new environment variable.
Select Environment Variable from Dynamic Content

Export your solution from the current environment and import your solution into a new Power Platform environment. You will have the opportunity to enter a new Business Central environment name and company id when you import the solution. No code changes will be required for your flow to access the new Business Central environment and company.


Conclusion

As we conclude our deep dive into the utilization of environment variables within Power Automate for Application Lifecycle Management (ALM), it's clear that the strategic application of these variables serves as a cornerstone for achieving seamless integration and deployment across various Microsoft Business Central environments. The journey from development, through sandbox testing, to production has been demystified, offering a structured pathway for developers and IT professionals to enhance the consistency, scalability, and integrity of their Power Platform applications.


Through the detailed steps outlined, from creating a solution in your development environment to exporting and importing it into new environments, we've illuminated the critical role that environment variables play in simplifying the development process. This approach not only streamlines the transition between different stages but also eliminates the need for code changes, thereby significantly reducing potential errors and saving valuable time.


The ability to seamlessly move solutions across development, sandbox, and production environments while adjusting Business Central environment names and company IDs on the fly showcases the flexibility and efficiency that can be achieved with a thorough understanding and application of environment variables.


As you embark on your next Power Automate project, remember the insights shared in this guide. Embrace the power of environment variables to transform your ALM processes, ensuring that your Power Platform applications are not just built for today but are scalable for the challenges and opportunities of tomorrow.


Let this guide be a stepping stone towards mastering Power Automate within the Power Platform ecosystem. As always, continue to explore, innovate, and share your discoveries along the way. The journey of learning and improvement never truly ends; it evolves, offering endless possibilities to those willing to delve deeper and push the boundaries of what is achievable within the realm of digital transformation.


Thank you for joining us on this journey. May your ALM processes be as fluid and efficient as the solutions you craft, propelling you and your organization towards greater heights of success and innovation.

32 views0 comments
bottom of page