
I have textinput in the Quantity column like this:
I want that when I change the value in textinput, I will save it to colAddCart, and if the value of textinput is greater than the available quantity in Sharepoint List Product, I will update the value of the available quantity and display the message. Here's the formula I used to solve the problem that wasn't.
Collection:
and the Product column will be associated with the SharePoint List Product:
Hope everyone helps me solve this problem. Thank you so much.
Hi @Edward00,
As I understand it, you would like to change the selected quantity to the max. amount available should the textinput be higher than the actual availability in your list?
I will use the Patch function instead of Update since this allows us to only add the fields that need to be updated. (removing the need to add Product & Size).
If(
IsBlank(tempcart),
//Should the tempcart be empty, show an error here
Notify("The selected item is invalid, please try again.", NotificationType.Error),
//In case it is not empty, check the quantity
ThisItem.QTY > ThisItem.Product.Quantity,
//Update with the max. available quantity
Patch(
colAddCart,
tempcart,
{
QTY: ThisItem.Product.Quantity,
TotalPrice: ThisItem.Product.Quantity * varAddCart.Price
}
),
//Use the TextInput quantity
Patch(
colAddCart,
tempcart,
{
QTY: Value(Self.Text),
TotalPrice: Value(Self.Text) * varAddCart.Price
}
)
)
If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.
Thanks!