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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Onchange in TextInput
Power Apps
Unanswered

Onchange in TextInput

(0) ShareShare
ReportReport
Posted on by 122

I have one gallery with quantity column like this:

Edward00_0-1689505662089.png

I want that when I change the value in the input box, it will not exceed the amount available in the stock.

The desired result is a value of 6

Edward00_1-1689505797472.png

My formula:

With(
 {
 wQty:
 LookUp(CurrentProductsStock,Product.Id=varAddCart.ID&& ThisItem.Size = Dropdown4.Selected.Value).Quantity
 },
If(
 Value(Self.Text) <= wQty,
 Patch(
 colAddCart,
 LookUp(
 colAddCart,
 ThisRecord.CurrentProductsStock.Product.Id = varAddCart.ID && ThisRecord.Size = Dropdown4.Selected.Value
 ),
 {
 CurrentProductsStock: LookUp(CurrentProductsStock,Product.Id = varAddCart.ID && ThisItem.Size=Dropdown4.Selected.Value),
 QTY: Value(Self.Text),
 Size: Dropdown4.Selected.Value,
 TotalPrice: Value(Self.Text) * LookUp(
 Product,
 ID = varAddCart.ID
 ).Price
 }
 ),
 Patch(
 colAddCart,
 LookUp(
 colAddCart,
 ThisRecord.CurrentProductsStock.Product.Id= varAddCart.ID && ThisRecord.Size = Dropdown4.Selected.Value
 ),
 {
 CurrentProductsStock: LookUp(CurrentProductsStock,Product.Id=varAddCart.ID&& ThisItem.Size = Dropdown4.Selected.Value),
 QTY: ThisItem.CurrentProductsStock.Quantity,
 TotalPrice: ThisItem.CurrentProductsStock.Quantity * varAddCart.Price,
 Size: Dropdown4.Selected.Value
 }
 );
 Reset(Self);
 Set(
 varShowWarning,
 true
 );
 
))

Because the quantity available in stock is 6. 

Edward00_2-1689505907566.png

My collection:

Edward00_3-1689505958023.png

Thank you very much.

 

Categories:
I have the same question (0)
  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Edward00,

     

    If the ColAddCart is the list behind the Gallery, you could use:

    With(
     {
     wQty:
     LookUp(CurrentProductsStock, ThisItem.Product.ID = ID && Size = Dropdown4.Selected.Value).Quantity
     },
     If(
     Value(Self.Text) <= wQty,
     Patch(
     colAddCart,
     ThisItem,
     {
     QTY: Value(Self.Text),
     TotalPrice: Value(Self.Text) * ThisItem.Product.Price
     }
     ),
     Patch(
     colAddCart,
     ThisItem,
     {
     QTY: wQty,
     TotalPrice: wQty * ThisItem.Product.Price,
     }
     );
     Reset(Self);
     Set(
     varShowWarning,
     true
     );
     )
    )

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 534

#2
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 306

Last 30 days Overall leaderboard