Ease the start of PowerAutomate Flows
1. The Story
Quite some PowerAutomate flows are based on SharePoint list data. The flows thereby may need to run either on all list items, items with the same value in a specific column or a single item.
There are two issues related to this:
- A user needs to go to PowerAutomate or open a specific URL to start the process
- You need to design the process start in a way, that the user can specify on what items the process should run
2. The solution
If you use the trigger “For a selected item”, a user can start the process conveniently right out of the SharePoint list (Menu “Automation”).
This trigger also allows to ask for user inputs. In our example (Fig 2) there are two yes/no (Boolean) and one text input fields.
Retrieving just the selected item is easy to achieve. Simply use the SharePoint “get item” action for the selected element.
Retrieving all items is likewise easy, using the SharePoint get items actions and leave the Open Data Protocol (OData) filter query blank, which returns all list items.
Retrieving all items with the column value as the selected item is still pretty easy, as the filter query can be designed high-level: NameOfStringColumn eq ‘SelectedValue’
It gets complicated, once you want to run your flow based on a user input to decide, to run it on all or a selected document only.
Key to solution is a smart (but complex) expressions for the OData filter query of the get items action.
Here is a working example:
if(triggerBody()[‘boolean_1’],”,concat(‘Title eq ”’,outputs(‘Get_item’)?[‘body/Ordernumber’],””))
The expression assumes, that the lists ‘Title’-column holds ‘Ordernumbers’.
The expression returns an empty string if the 2nd yes/no option in the flows starting dialog (fig 2) was selected (true) otherwise the string
Title eq ‘234’ , if 234 was the Ordernumber of the selected list entry.
This OData query string, return the selected list item only.
The if-expression has the following syntax:
if(expression, valeueIfTrue, valueIfFalse)
triggerBody()[‘boolean_1’] is the 2nd Boolean value we test on true or false
” The two apostrophes return the empty string
The false value concat(‘Title eq ”’,outputs(‘Get_item’)?[‘body/Ordernumber’],””)) concatenates the strings
Title eq ‘ and 234’