web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Automate
Answered

Update item quantity

(0) ShareShare
ReportReport
Posted on by 57
Hi all, I already made a post about this but the issue was not resolved.
I am trying to connect two SharePoint Lists for Ordering and Inventory. The Inventory List will be updated based on the activities of the Ordering List.
 
This is how I want the Flow to work:
  • Item is created/ modified: Item in Ordering list is updated,
  • Get Items: Get items from Inventory list.
  • Condition: Is the Status of the item in the Ordering list equal to Received?
    • No: Do nothing.
    • Yes
      • Condition 2: Does the Product Name of updated item from Ordering list exist in the Inventory list?
        • No: Create new item in Inventory List with values from Ordering list.
        • Yes:
          • Update item: Update Quantity of item in Inventory list - Current Quantity + Ordering list Quantity
 
I understand that Get Items returns an array but I don't understand how I can get one individual item to be updated or an individual item to be created.
The items are not compatible with ID because there will likely be multiple orders for the same products and I want the history of each order, but I only want one product existing in the Inventory List.
When I use the Update Item feature, because of the Get Items array, Power Automate puts in an "Apply to Each" which keeps giving flow failures either in saving or the flow gets to the Apply to Each and stops.
 
My question is how to achieve this?
 
Any assistance would be highly appreciated!
Attaching the pictures of the flow in its current setup.
 
 
Categories:
Inventory Flow Pa...
Inventory Flow Pa...

Your file is currently under scan for potential threats. Please wait while we review it for any viruses or malicious content.

I have the same question (0)
  • Suggested answer
    rzaneti Profile Picture
    4,267 Super User 2025 Season 2 on at
     
    You can directly reference the index of the desired Get items element between square brackets in an expression. For example, if you want to access the first record retrieved by Get items, you would work with an expression like body('Get_items')['value'][0], where the zero means the position in the array that want to access. Since the count starts at zero, our expression is accessing the first element.
     
    You then will be able to access individual properties from the record at the same expression. As each record is represented as an object, you will simply need to pass the property name between square brackets. 
     
    Based on your description, I recommend the following content as further reference:  
    - Using loops and accessing array elements in Power Automate: https://digitalmill.net/2023/07/12/using-loops-and-accessing-array-elements-in-power-automate/
    - Video - Using dynamic content in Power Automate: https://youtu.be/jpledJfaEPQ
     
     
    Let me know if it works for you or if you need any additional help!
     
    If this is the answer to your question, please mark the post as Accepted Answer.
    If this answer helps you in any way, please give it a like.

    Check more Power Platform content on my website.
    Lets connect on LinkedIn.
     
  • TM-11021013-0 Profile Picture
    57 on at
    @@rzaneti I appreciate your assistance with those links. While they will help with more general knowledge and improving my skills, it doesn't help in my current situation outlined in my question.
     
    My question is mostly on how I can add two numerical fields together.
     
    For example, over 1-month, there will be multiple requests to order "A4 notebook", but there will only be one Inventory item that is "A4 notebook".
    I want each order request to be able to connect to only one inventory item based on the Name of the item (e.g. "A4 notebook").
     
    I have updated it a wee bit with ChatGPT's help and had some improvement but running into ID issues.
    It seems to be incapable of making a many-to-one relationship.
     
    This is how I have my current setup with the Flow:
     
    Condition 2 is: length(outputs('Get_items')['body/value']) is greater than 0
    ^ Intended to check that the item exists. If length is less than 0, then item does not exist and item is created in the Inventory List.
     
    In Update Item
    ID: outputs('Get_items')?['body/value'][0]['ID']
    Quantity: add(int(outputs('Get_items')?['body/value'][0]['Quantity']), int(triggerOutputs()?['body/Quantity']))
     
    Unfortunately, the ID is not working as intended and will only update the first item in the Inventory List with the new quantity.
    If the Product Name does not match the first item in the Inventory List, it will still update it with the new quantity BUT will also create a new item with the correct name and the correct quantity. When repeated, I have multiple items with the same name but only the first item (with the wrong Product Name) is getting the updates.
     
     
     
  • rzaneti Profile Picture
    4,267 Super User 2025 Season 2 on at
     
    Thank you for the additional context: I misunderstood your request and recommended to use the [0] as an alternative for the Apply to each. 
     
    Just clarifying: the [0] in your expression means that only the first record from an array will be retrieved. Based on your description, that's exactly what's happening, but the retrieved result is not the desired one, since it always match to your first SP List record, which sometimes won't match the ordered product.
     
    According to the shared images, it looks like you are not applying a filter to your Get items actions, so you are always retrieving all records from Inventory List, independent on which product was order. You may need to add a filter query to your Get items, setting the product name column to match the name of the ordered product.
     
    For filtering the Get items, you will need your Product name column internal name, and then you can use a query such as [product_name_column] eq [trigger_productname_dynamic_content]. As a result, Get items will retrieve an array containing only those records from Inventory List which name matches to the ordered product. You can refer to this video on how to work with filter queries: https://youtu.be/Ifqo1YKMiw0
     
    To identify your SharePoint column's internal name, you can refer to chiaraalina's response in this thread: https://community.powerplatform.com/forums/thread/details/?threadid=23cbc4bb-78dc-ef11-a730-7c1e52581318
     
    Let me know if the steps above makes sense, and if you need any additional clarification. I'm pretty sure it may solve only part of your problem, but then we can focus in the rest of your flow :)
     
    If this is the answer to your question, please mark the post as Accepted Answer.
    If this answer helps you in any way, please give it a like.

    Check more Power Platform content on my website.
    Lets connect on LinkedIn.
     
     
  • Verified answer
    TM-11021013-0 Profile Picture
    57 on at
    @@rzaneti Many thanks for the message, this was exactly the error. I created a separate Flow (Manual Trigger -> Get Items) and then read the column names. This column's internal name was ItemName instead of Product Name (a leftover from an earlier attempt).
     
    I changed some things as well:
    • Previously, to check if an item existed in the Inventory List, I used the "length()" expression - if the result was 0, then the item didn't exist.
      • This would sometimes result in a failure to find the item, which means that no length could be found, but instead of taking that result as 0, the condition took it as the condition being satisfied and a YES.
    Instead, I used Parallel Branches after the Get Items.
    If the Get Items fails, it means that no corresponding item can be found - therefore, an item is created.
    If the Get Items succeeds, then it checks to see if the list is empty (if yes, it creates new item; if no, it updates existing item)
    • I notice that if the list is empty, the Get Items will also run successfully, so I added the second condition to check if the list is empty with the length() expression again to be on the safe side. And this worked nicely with the Get Items and the Filter Query.
     
     
     
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 519 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard