Hi all,
I want to make an automated flow that counts the existing items in a list based on the metadata from a new added item.
For instance a list has the following items:
Title | Observation | Program |
1_Bug_Windows | Bug | Windows |
1_Calculation_Mathcad | Calculation | Mathcad |
1_Layout_Python | Layout | Python |
2_Bug_Windows | Bug | Windows |
Now I add a new item to the list with 'Title' = Errror, 'Observation' = Bug, 'Program' = Windows.
The automate flow has to go through the existing items and return the number of items that match with the metadata (Observation and Software) of the new added item. In this example it should return item 1 and item 4.
It then should count the number of items including the new added item (e.g. 3).
Reason is that I want to force the title to be unigue to the entry (see example). The title is now something which it to be included manually but, with every new added item, one has to check which follow number is to be used.
How can I achieve this?
I already managed to get title renaming working for a library, with great help from @efialttes (see: Library count) but this does not seem to work the same for lists.
Your help is greatly appreciated.
Regards,
Martin
Hi @mar01
Please try the below; Get Items with Filter Query
Then use the expression below in the compose action to get the number of items:
That does not seem to work nor do I understand what you exactly mean.
It needs to filter the items from the list based on the item metadata that is changed or newly added.
I have this:
can you Construct the filter Query? as in the my previous screen shot using the variables you have constructed?
Observation eq ObservationID and Program eq SoftwareID
That does not work either assuming that Program == Software:
Observation eq ObservationID and Software eq SoftwareID
I get an error which seems logical as the column is called 'Observation':
Column 'ObservationID' does not exist. It may have been deleted by another user.
clientRequestId: 8b09f45d-0eca-4849-b8c3-317134a7604f
serviceRequestId: 8b09f45d-0eca-4849-b8c3-317134a7604f
I tried the following as filter query:
The variables ObservationID and SoftwareID are taken from the changed/added item (e.g. triggerOutputs()?['body/Observation/Value']
What am I doing wrong?
I understand that the left hand side is the column name but, for some reason that does not work whereas they are as they are called now. Is there a different way to get the information without using the filter query in 'Get Items'?
If it does not work then you need to check the column name in your sharepoint list to make sure it is the same spelling and case sensitive.
I can't think of a way other than the GetItems Filter Query.
It seems that, if you use a variable in your filter query, you need to include the " ' " too.
The attempts were:
1. Observation eq @{variables('ObservationID')} and Software eq @{variables('SoftwareID')} > fail
2. (Observation eq @{variables('ObservationID')}) and (Software eq @{variables('SoftwareID')}) > fail
3. (Observation eq '@{variables('ObservationID')}') and (Software eq '@{variables('SoftwareID')}') > success
Seems that if you do not include " ' " is considers the variable to be a column name.
That problem is solved but, it leaves me with some other issues.
It seems to cause a infinite trigger loop, resulting in overwriting all the items that match the criteria.
See below flow I used.
Any idea why it is overwriting the title of all the items that match and not the only the one that is created/modified?
User | Count |
---|---|
88 | |
39 | |
23 | |
20 | |
16 |
User | Count |
---|---|
127 | |
49 | |
46 | |
31 | |
25 |