Subtleties of Power Automate and Logic Apps. Citizen developer'a reference guide # 1

Good day to all! In one of my previous articles, I talked about what features Power Automate and Logic Apps cloud services have. We examined the main differences between them, studied in which cases one or another service should be used, and also got acquainted with some usage scenarios. Today I would like to start a new series of articles devoted to various life hacks and workarounds that will allow you to implement a number of business scenarios using available tools.



Let's not waste time and look at one of the scenarios today, namely:

Launch Logic Apps stream by button from Power Apps


In some cases, during the design and configuration of various system modules, it is more profitable to use Logic Apps than Power Automate. There may be many reasons for this, but one of the most popular is the presence of premium connectors in Logic Apps without buying additional plans, such as Power Automate. For example, inside a stream, you may need to make an HTTP Web service call and connect to SQL Server, but in Power Automate these connectors are not available without buying a special plan for users or for streams. In this case, Logic Apps will help us, where a slightly different tariffing mechanism is used and all connectors, including premium, are available initially. You can read more about the features of Logic Apps in this article .

However, there is one feature - Logic Apps stream cannot be launched by a button from a form or Power Apps application, unlike Power Automate stream. How to solve this problem? In fact, the solution is quite simple. Consider this case as an example of the process of applying for technical support.

So, in our case, we have a SharePoint list of “Technical Support Applications”:



Additionally, the list has customization of the form using Power Apps:



As you can see, in the form header there is a transition to an additional screen with action buttons for the selected application:



Click "Delegate Application" and fill in the additional fields:



Using the “Confirm” button, you need to start the Logic Apps stream, but we do not have the ability to carry out this operation directly. Therefore, we will try to do a little differently.

Create an additional ActionsList on the SharePoint site and add several fields:

  1. ActionType - type of action to call
  2. Comments - Comments
  3. ParentItemID - identifier of the parent element (application)
  4. DelegateTo - additional field for storing the delegate
  5. CompleteProcessFlag - action processing flag



Now, from PowerApps, we create an element in the ActionsList list by clicking on the “Confirm” button:



Using the Patch function, create a new element in the ActionsList list with the “Delegate” type and transfer the remaining control values ​​from the form. Check that the item is created:



Now we can go to Logic Apps. We go to Azure, create a new Logic Apps stream and specify the trigger “When creating an item in the SharePoint list”:



We make the stream with the switch:



The logic of this stream is as follows:

When creating an element in the ActionsList list, the flow rises, checks the value of the "ActionType" field of the new element and, depending on the type of action, goes to one of the switch branches where the required logic is processed. Thus, we can make as many branches as you like for the switch in one thread and process any events within the same thread. It remains only to create elements in the ActionsList list with the desired event types and add support for these types to the stream, in the form of additional switch branches.
Let's do another event creation from PowerApps, for example, to cancel an application:



In this case, a new event will appear in the ActionsList list with the type “Reject” and comments for cancellation. Be sure to pass the value of the identifier of the parent element, otherwise it will be very problematic to find the required order from the stream later. Next, add support for the new event type in the Logic Apps stream. We make one more branch in the switch:



And it remains to add to the very end of the stream an update of the processing flag, in order to understand which events are processed by our stream and which are not:



This flag will help in case of unforeseen situations during which the processing of the event by the thread is unsuccessful. It will be possible to make a thread, which, for example, will rise twice a day according to a schedule and process events in the ActionsList list, whose flag “CompleteProcessFlag” is No.

The mechanism described in this article has been successfully implemented and works stably for several clients. In conclusion, I would like to say that there are a lot of interesting features in the Power Platform that may not be visible at first glance, but they can be very helpful in implementing various cases. In the following articles I will try to show you even more possibilities. Thank you very much for your attention!

All Articles