I am working on Teams power app.
Trying to use the below code in the gallery, that If the stockQty is less than the user's Input Qty then error message and set the Qty as the stock Qty
The default property of the TextBox is 1, therefore I put OnChange prorperty of the text box the below code:
If(ThisItem.StockQty<Value(Self.Value),ThisItem.StockQty;Notify("stock Qty is less than order",NotificationType.Warning,3000),Value(Self.Value))
During Testing the code found, Currenty Stock is 5, when the Input Qty is more than it brings the notification , but does not set the StockQty as the value the textbox.
I want if the user Input Qty is less than stock, then let the user qty as it is, BUT if User's Input Qty is more than Stock, the set the textbox value to StockQty.
Please advise what changes to be done in my above code.
Of course you can! As long as it is a unique ID you can use this for your Updateif
Also please advise for the ID part which I posted in earlier reply.
ID=ThisItemID
The table is based on Teams Table (Dataverse), therefore in Dataverse there is No ID column by system.
Can I use PartNo field as it is unique and has no duplication.
Sorry for the typo
The record {Qty:ThisItem>StockQty}
Should be {Qty:ThisItem.StockQty}
so you write the StockQty value of the item in the gallery to its Qty row.
Please LIKE the reply and ACCEPT it as the solution if the answer is what you were looking for.
(to help me grow in community rank and help others find the solution)
Sorry not getting clear in the below line:
UpdateIf(CollectCardItems,ID=ThisItemID,{Qty:ThisItem>StockQty});
ID=ThisItemID
The table is based on Teams Table (Dataverse), therefore in Dataverse there is No ID column by system.
Can I use PartNo field as it is unique and has no duplication.
{Qty:ThisItem>
Is Qty is declaration for the situation?.
ThisItem - is referring to what ?.
Please guide, I want to understand and then apply to my application.
Okay, so now what you would have to do is update your value in the collection
If(ThisItem.StockQty<Value(Self.Value),
UpdateIf(CollectCardItems,ID=ThisItemID,{Qty:ThisItem>StockQty});
Notify("stock Qty is less than order",NotificationType.Warning,3000);
and keep the default value to Thisitem.Qty
That should do the trick.
Please LIKE the reply and ACCEPT it as the solution if the answer is what you were looking for.
(to help me grow in community rank and help others find the solution)
once the updatecontext triggers, it impact the on the all items of the carted gallery, I mean on all the row of records.
Similar test result I already posted in the earlier reply.
In that case it was Set() function, in your advise it is UpdateContext(). In both coding the default value gets impacted for next new records.
Any other idea.
hey @MIA27
can u try this:
UpdateContext({currentQty: 1}) // Sets default quantity as 1
onchange:
If(
Value(TextInput1.Text) > ThisItem.StockQty,
UpdateContext({currentQty: ThisItem.StockQty}),
UpdateContext({currentQty: Value(TextInput1.Text)})
);
If(
Value(TextInput1.Text) > ThisItem.StockQty,
Notify("Stock quantity is less than the order", NotificationType.Warning, 3000)
)
default of text box:
currentQty
Let me know if my answer helped solving your issue.
If it did please accept as solution and give it a thumbs up so we can help others in the community.
Greetings
I am using a collection based on another gallery.
I am developing an Parts Store Inventory application - Power App in Teams - the table are based on Dataverse,
As shown in the below image,
User selects from one gallery, then the collection is used in the carted gallery to input the items he needs, then this collection is been used to store the order placed and same time, it will updated to the stock.
I am stuck in the mid way now.
On the carted Gallery, in the items property is the collection name
Ah, of course. Then you should do the same trick, but not with a variable but with the items in your Gallery. What are you using as Items property for your gallery? a collection or a direct connection to a SharePoint list? Could you share the code of the Items Property in your Gallery?
And also please note, it store the Value of StockQty in VarStockQty,
And applies to any new added items to collection, which is not correct. for example
I added an item, it was more than stock, example 7. it correct after change to 7
but next new record CartQty became 7, while its actual stock is only 5
So it went beyond control.
It must be controlled, lets say, example must be set to 1 back.
Pls. guide
WarrenBelz
146,660
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional