Instance counter using microsoft flows / power automate
-
08-02-2021 - |
Pregunta
I have a SharePoint list that captures employee details and the error types they have committed. In the same list, I would like a column to auto-capture the number of instances of each error type when we select from the error type column.
Example:
Emp ID: 123 error type : err1 Instance :1
Emp ID :234 error type : err1 Instance 1
Emp ID: 123 error type : err1 Instance :2
Emp ID :234 error type : err2 Instance 1
How could I achieve this using flow / power automate?
Solución
-- NOTE: First be sure to determine the Internal Names of your fields, that is what you need to use in the filter parameter in Flow (e.g. if the display name is "Emp ID", then the internal name is likely either "EmpID" or something like "Emp_0x020_ID") -- for the purposes of the below steps, I will assume the internal names are "EmpID" and "ErrorType".
- Create a Flow that is triggered only on Item Create.
- Use a
Get Items
action, and use the 'Advanced Options' to set aFilter Query
option on that action to filter whereEmpID eq [InsertTriggeredEmpIDFromDynamicValues] and ErrorType eq [InsertTriggeredErrorTypeFromDynamicValues]
(note thatFilter Query
follows the syntax rules of the REST ODATA filter) - Finally use an
Update Item
action, using the ID of the triggered item from Dynamic Values to choose which item - Set the Instance value to a Dynamic Expression
length(body('Get_Items')?['value'])
(adjustGet_Items
if the name of your Get Items action is different).
Another --NOTE: Power Automate Flows do not always run immediately, it may take 5-10 minutes before your Flow executes after the item is created.