Hello! I'm trying to build a flow that deducts a value from one list to another; essentially acting as an inventory/delivery flow.
The list I have with the value that needs to be deducted is here:
The list with the value that should be the deducted amount is here:
So I need it to recognize the value in the 2nd list in the quantity column, then deduct that value from the quantity in stock column in the first list, once it goes from Pending -> Delivered. How can I make this happen? Thank you!
Anyone able to assist with this by chance?
Good morning all, still looking for support on how to achieve this, if anyone knows how - thank you!
The easiest way to do that is going to be to setup a flow on the second list that is triggered when an item is modified. If the status column is delivered then look up the matching entry in list one and update the total by deducting the value. To keep if from firing twice I would add another status to the Pending/Delivered column. A status of Posted. In the flow that deducts the value set the status to Posted after it has been deducted. That will keep it from being deducted twice.
That makes sense, I changed column and added that final step, but how would a flow look like to achieve all of this? I've tried a couple where I have:
1. When a file/item is modified (order list)
2. get items (inventory list)
3. set variables (for both number columns in order and inventory list)
4. subtraction (inventory list by the variables from the order list)
But that didn't work. I'm pretty new to PowerAutomate so any guidance you have would be most appreciated, thanks!
1) When an Item is modified Trigger on the second list (the one with the status column).
2) Test to see if the Status column is Pending. If it isn't do nothing (this would be more efficient with a trigger condition)
a) if it is "Pending" then lookup the corresponding item in the first list (Inventory) and subtract the quantity
b) Update the item that originally triggered the flow to status = "Posted"
Understood - when I tried to subtract the two columns in the lists I got an error, "Enter a valid number"
Do I still need to set and initialize variables for this?
And when I try to initialize them as variables I get this error:
Flow save failed with code 'InvalidVariableInitialization' and message 'The variable action 'Initialize_variable_3' of type 'InitializeVariable' cannot be nested in an action of type 'Apply_to_each_3'.'
How would I go about un-nesting the initialize variable part? Every time I use get items and initialize variable it automatically nests them. 😕
Looks like the issue is that you aren't using the Expressions tab in the dynamic content dialog to enter the Sub() function. Its reading Sub( in your entry as a string not a function.
Gotcha, I changed it within the expression builder to this:
This is the error I get when testing it:
You can't just use the column names in the Expressions Tab. You either have to switch back to the dynamic content tab and insert the values or type in the JSON addresses of those values. If you hover over one of the fields you'll see what I mean by the JSON address. It will be something like
items()['ColumnName']
User | Count |
---|---|
87 | |
37 | |
25 | |
13 | |
12 |
User | Count |
---|---|
116 | |
55 | |
36 | |
23 | |
21 |