Maximize Efficiency with Template Tasks: Data vs Logic Separation
Image Source:
Power Automate
Sep 27, 2023 1:02 PM

Maximize Efficiency with Template Tasks: Data vs Logic Separation

by HubSite 365 about Ben den Blanken (Power Addict Ben) [MVP]

Microsoft Business Applications MVP, Power Platform Lead at Dynamic People

Citizen DeveloperPower AutomatePower SelectionM365 Hot News

Unleash efficiency with Template Tasks - separate data and logic, streamline your workflow with Microsoft expert guidance!

In our dynamic, data-fueled society, it's become critical to keep data and logic apart while developing applications. Maintaining this distinction not only enables better code organization and maintainability but also facilitates efficient data management. The focus of this blog post, penned by Ben den Blanken (popularly known as Power Addict Ben), revolves around the utilization of Template Tasks to uphold this separation of data and logic, thus empowering applications to be more manageable and efficient.

A key expansion to a prior post is presented by the author, where Tasks were produced via a Custom Page. However, aiming for simplicity, the post had overlooked elements like Description and other fields, leading to clean Power FX logic. A work-around to maintain this cleanliness while incorporating data is the use of Template Tasks. By depositing the data inside Dataverse and resorting to template tasks to spawn tasks based on logic within the Custom Page, a more adaptable and scalable workflow is achieved.

The primary advantage of isolating data from logic is the accessibility it provides, allowing anyone to customize the Template Tasks. As a result, users can add detailed task descriptions without having to tweak the Power FX on the Custom Page. Furthermore, the Template Tasks can be highlighted within a special administrative Model-App, or specific views and forms can be shown using a security role.

This approach also lends clarity to the app logic. The initial blog post had a switch and several 'if' statements that, enhanced with large descriptions, would complicate its readability. The author advocates the importance of readable and comprehensible logic, an essential skill even in the low-code realm!

Once the benefits of Task Templates are grasped, it's time to set them up. A couple of new columns are added to the standard Task table—'Is Template Task', which indicates if the Task is a Template, and 'Type', filled with all the different template Tasks that need to be generated. For the creation and editing of a Template Task, a specific admin Form is required, where the Yes/No field is set to 'yes' for a Template Task.

Now, let's enhance our Custom Page, which is based on a collection of all Template Tasks, to be used later to generate Tasks. The Power FX for this process is as follows:

Finally, the OnSelect of the Generate button allows us to add LookUps to the Subject and Description of our Task Templates.

Key Takeaways and Deeper Analysis

Separating data from logic in application development has numerous advantages, such as improved organization, maintainability, clear logic, and ease of data management. Tools like Custom Page, Template Tasks, and platforms like Dataverse can facilitate this process in a low-code environment, making it accessible and efficient for both developers and administrators. To explore more about Template Tasks, you may refer to this detailed guide here.


Read the full article Use Template Tasks to separate data from logic

Power Automate - Maximize Efficiency with Template Tasks: Data vs Logic Separation

Learn about Use Template Tasks to separate data from logic


Technology has taken a significant leap forward, intertwining with almost every aspect of our lives. With this in mind, it has become increasingly crucial to separate data from logic during application development. A process that's pertinent to ensure orderliness and easy maintenance of code. Also, it aids in better data management making applications more efficient and user-friendly.

In this article, we delve into how Template Tasks can be used to disentangle data from logic. To further expand on this, we will use a previous blog post where we created Tasks using a Custom Page. It showcased how to produce tasks intended to aid users in their work. The executed job, though basic, didn't include a description nor covered all fields, hence utility the provided by Power Fx seemed adequate.

To maintain ease of use, incorporating Template Tasks offers a way out. It provides a means to store data in Dataverse, allowing the generation of tasks based on logic within the Custom Page, thereby resulting in a more adaptable and expandable workflow process.

The core advantage of using Template Tasks lies in the flexibility it offers. Any user can edit Template Tasks, so it no longer becomes a necessity to edit the Power FX in the Custom Page when a detailed description needs to be added to a Task. It's possible to access Template Tasks inside a special administrator Model-App or ensure a security role to display specific views and forms.

In the previous blog post, there was already a switch and several 'if' statements. If large descriptions are added, it could obscure the actual logic, making it less clear. Hence, creating easy-to-understand logic is crucial even when using low-code platforms!

Having understood the benefits, let's step into setting up Task Templates. You should add 2 new columns to your standard Task table.

  • A Yes/No column to indicate if the Task is a Template
  • A Choice field which will be filled with every different task template we want to generate

Create an admin Form designed to create and edit a Template Task. Each Task we generate in the Custom Page should have a corresponding Task Type. Ensure setting the Yes/No field to 'yes' when the Task is a Template Task.

At this juncture, we've set the basis to extend our Custom Page. We need a collection of all Template Tasks to generate Tasks later. Add the following Power FX on the OnVisible of the Custom Page:

ClearCollect(colTemplateTasks, Filter(Tasks, 'Is Template Task' = 'Is Template Task (Tasks)'.Yes));

Consequently, on the OnSelect of the Generate button, we add LookUps to the Subject and Description of our Task Templates. This approach allows for maximum flexibility with the tasks and descriptions, ensuring a smooth and user-friendly experience.

Overall, the use of Template Tasks aids in separating data from logic, resulting in more structured and easily managed applications. And remember, anyone can edit Template Tasks, characterising the flexibility of the system and the allowance for clear app logic to be maintained.



Template Tasks, Separate Data From Logic, Data Separation, Logic Separation, Using Templates in Programming, Data and Logic Dissection, Task Templates, Implementing Template Tasks, Code Optimization Techniques, Programming Structure Improvement