Good morning. I'm trying to build an inventory flow that can automatically update stock quantities between two different SharePoint Lists, based on statuses and I need some help! What I have so far is this:
I'm not entirely sure if it's set up correctly, but it definitely doesn't run as intended, the last test I ran resulted in this error:
with the error stating, "Unable to process template language expressions in action 'Update_item' inputs at line '0' and column '0': 'The template language function 'sub' expects its first parameter to be an integer or a decimal number. The provided value is of type 'String'. Please see https://aka.ms/logicexpressions#sub for usage details.'."
I've tried a number of times to set and initialize the quantity columns in both lists as variables earlier in the flow as well, to no luck. What am I missing?
Also, in the flow I need to ensure that it only runs the quantities updates based on if the two columns between the lists (product name) match. I don't think my current flow has that anywhere, how would I achieve that?
Please bear in mind I'm very new to PowerAutomate flow building.
Thank you kindly for your support!
Looking for some assistance on how to accomplish this - thanks!
@Applications I'm not sure that your issue here is wholly power automate, mate ... take a look at exactly how the number that you're using in that sub() expression is presented on a test run, to see what type of data it is.
More often than not, number columns in SharePoint are either presented as 'floating point' numbers (1.0 instead of 1), strings ("1") ... or both ("1.0"). You *can* create pure integer columns in SharePoint, but you can also translate them down in Power Automate.
For example, this:
|
First of all float() changes the Version number (which lists as "2.0") into a floating point number, then formatNumber() changes it into a single digit, then int() changes the string into a proper integer value.
I see, thanks! As far as putting that into an operation, would that be before the subtraction step? And which operation would you use? Or does this supplant the subtraction formula I have in currently? If so, where within that formula would I point to the two columns within each list? Thanks again!
Well, you'd need to show us your sub() expression. 😉
@Applications wrote:
I see, thanks! As far as putting that into an operation, would that be before the subtraction step? And which operation would you use? Or does this supplant the subtraction formula I have in currently? If so, where within that formula would I point to the two columns within each list? Thanks again!
Of course! Here is my current sub() expression:
Ah, OK, well your main issue here is that you aren't actually performing any maths, there.
What your expression is actually trying to do is subtract the phrase "Quantity in Stock" from the phrase "Quantity" ... and I think that most maths programs will have some trouble with that, @Applications 😉.
( hope that it is clear that I'm not being rude, here, just playful! 🙂 )
You need to refer to actual columns, or literal values that you have defined somewhere else. This brings us neatly onto your second issue ...
Can you show me the value of the 'Quantity in Stock' column for a few items, @Applications ?
Perhaps just create a temporary flow (which you can delete afterwards) which runs a Get items on the list, and then for each one have a compose that shows that value.
Then just show screenshots of 2 or 3 of them.
This will assist in anything that you're doing ... I'm writing a 'generic' answer for you, but this will help you to be more prescriptive yourself in building the final solution.
Now that I'm looking at all of this, it's really unclear what one list does, and what the other list does ... then what the synching between the lists will hope to achieve.
If you can more clearly define that here, it will help someone give you a very specific solution to what you need here. To help yourself on this (in case it's unclear to yourself), try the next thing ...
Sit down with a pen and paper, and work out how the data in both lists relates to each other.
You might be able to do a lot of easy stuff without using flow, here, by referencing data between lists using 'Lookup' columns.
I *think* I know, but currently it's unclear which values 'Quantity in Stock' and 'Quantity' are referring to.
So, even though I can make educated guesses, this flow may need to be seen, used, or maintained, by other people, so you need to make some clearly defined data.
So, in order to both help yourself, and to help others, you need to define some information in this flow that makes sense in the context of what it is trying to do.
So, below I will make some assumptions, be sure to take what I am writing here GENERALLY. It is general advise on how to proceed, not *exact* things. Use it to create similar things on your end and don't view it as a literal, prescriptive, "do exactly what I say" solution.
So, I am going to guess that you might need here:
So you should define these as variables.
I will assume that the value in that column is always a whole, integer, number (1, 2, 3), and is stored as such. If it is stored as "1.0" or as a string (text) value, then you will need to do more work on it (hence my previous comment in this thread).
So (assuming it is an integer) after your Get changes ... action create three Initialize variable actions for an integer values and name them as follows;
Use the previous version value in the first one, the new value (from the trigger) in the second one, and in the third, you can use that sub() expression, except here it would be:
|
Now you can use the number that has been created in the differenceStockQuantityVAR anywhere in the flow, and it will be immediately obvious what it is.
Once you have got your head around referencing the values in certain parts of the flow, you can start to do more with it, and even do things without the variables (like you're currently trying to do).
However using the variables will help you see the logic more clearly whilst you're starting out. 🙂
Here is a screenshot of the SharePoint list that has the column values (Quantity in Stock)
And after building the test flow for the compose, here are those results:
1:
2:
3:
So what I'm trying to achieve is this:
What I've done so far is start an automatic flow for when the status in List 2 changes to "Delivered", Get Items from List 1, and try to subtract those, but I understand from the post above, it's trying to subtract the phrases rather than the values (lol). I'm still new to all of this, but your guidance has been absolutely amazing - and with the step above with the compose and seeing that they are indeed being composed as values, gives me hope haha.
sub( variables('previousStockQuantityVAR'), variables('newStockQuantityVAR') ) |
When I try to initialize variable for the Get Items (List 1), it turns it into an Apply to Each control and then I get an error when trying to save it:
Here is what my overall flow looks like now though:
Hope this helps with some clarification on what I'm trying to do vs. what I currently have - thank you! @eliotcole
I've not got too much time to look fully at it now, but this will all really help, @Applications ... thanks! Whomever does help you with this ... or me ... will have a much easier time knowing this.
🙂👍
Pure instinctual reaction has me thinking you should have 2 flows with maybe two or three extra columns in list 1.
Where availablestock will always be the formula:
|
So 'stock' will always indicate the total amount, but available stock will show what's available for other orders which might come in seconds afterwards.
Maybe some time in the future you can work out a system to identify individual order amounts in there.
Now you have a system that will ensure that stock levels are not only accurate, but also ensures that orders which are in progress won't impact other orders.
Obviously this is all around other processing here, and maybe other flows, but separating these two actions up like this will really ensure that it runs smoothly, I think.
As an example of potentially useful stuff that you could do which wouldn't need Flow at all ... I'd also recommend that you play with Lookup columns in List 1 which show which orders in List 2 are currently live. These lookup columns wouldn't have to be visible on all views, but they could be invaluable for understanding the data.
If I can I'll come back and try to do something for you. Otherwise, I'm sure someone else will have a pop ... good luck!
Understood! For the Flow 1 - New Orders portion, I don't think that's needed because within the PowerApp built it has some of that logic within the stock visualization process, so not needed within PowerAutomate. The other aspects I concur with and that's exactly what I'm looking for - thank you! I look forward to your (or anyone elses) support. Thank you!
Good morning! I tried modifying the flow based on the test we conducted yesterday, using Compose as a method to see if the columns were outputting integers, but it failed this morning. Is this an appropriate modification, or unnecessary? Thanks!
Modification:
Compose -> Quantity in Stock column in List 1
Initialize Variable -> Output of that
Compose -> Quantity column in List 2
Initialize Variable -> Output of that
User | Count |
---|---|
89 | |
41 | |
22 | |
20 | |
16 |
User | Count |
---|---|
138 | |
56 | |
47 | |
36 | |
25 |