Hi Ken, what is the result of what you are trying above then? Are there any errors? Is the value not getting updated at all or is a wrong value updated?
Can you check the data store in the Dev Tools > Application section and check if everything is initially inserted properly?
So if the data store is empty, the insert action is not inserting the qty?
And then on clicking the button again it also does not add/update it, correct?
Try using a flow with 2 upserts. The 1st upsert stores the input quantity. The 2nd upsert adds/updates the quantity with the quantity + the input quantity.
The problem is that when the record doesn’t exist it doesn’t have a qty value, so it will be undefined.
A workaround for it is changing the expression to qty.default(0) + inp_qty.value.toNumber().
To fix the actual issue we probably have to extend the scheme for the data store. To handle this kind of issue we need a default value for the column and maybe just like with databases an allow null option. That way we could use the default value when no value was set. When allow null is enable it could insert a null value and if no default or null value is allowed it should trigger an error.
Let me know what you think about that proposal, it would mean a big change to the current component. The workaround is also simple enough to get around the current restriction.
I think that it doesn’t get the value because it can’t find the input. I have to check, but I believe it evaluates the expression in the scope of the datastore component and that component is probably placed outside the form on your page. You could move the datastore component next to the button and see if that fixes the issue.