Hello everyone, recently I will ask a lot of questions on the forum but this is because I am just getting to know powerapps, and its syntax is not fully understandable to me.
I have a gallery that contains a list of assortments and an inputText field where we enter the number of items of a given item and add it to the collection. Thanks to the "Gochix" user, the button in the gallery for adding an assortment to the gallery does not duplicate a given item, but adds the number of items if a given item has already been added to it.
In addition to the gallery, I have a button that is used to add to the collection all items for which the InputText field is filled. And now, will you help me to make this button also check if a given item already exists, and if so, it will sum it up, and if it is not there, then it will be added to the collection.
here is the code from "Gochix":
With({
aLookup: LookUp(Zamowienie; nazwa_asortymentu_do_dodania.Text = Nazwa)};
If(IsBlank(aLookup);
Patch(Zamowienie; Defaults(Zamowienie);
{
Ind: ThisItem.Indeks;
Grupa: ThisItem.Grupa;
Nazwa: ThisItem.'Nazwa asortymentu';
Jednostka: ThisItem.'j.m.';
Liczba: Value(liczba.Text)
}
);
Patch(Zamowienie; aLookup;
{
Ind: ThisItem.Indeks;
Grupa: ThisItem.Grupa;
Nazwa: ThisItem.'Nazwa asortymentu';
Jednostka: ThisItem.'j.m.';
Liczba: aLookup.Liczba + Value(liczba.Text)
}
)
)
)
and here's my code for a button outside of the gallery that adds all items where InputText is filled (InputText field is called "liczba"):
ForAll(Filter(Asortyment_lista.AllItems;Value(liczba.Text)>0);Collect(Zamowienie;{Grupa:Grupa;Nazwa:'Nazwa asortymentu';Liczba:liczba.Text;Jednostka:'j.m.';Ind:Indeks}))
Now the second problem, which seems simple and probably is for most of them, but I've been struggling with it for a few hours and I've already done some solutions from the forum but either I get an error or the button just doesn't do anything. The point is that next to the InputText field in the gallery where I enter the number of items (before I add it to the collection) I would like two buttons
1. Add +1 to quantity button
2. Subtract -1 from the quantity
I would also like to thank everyone for their help and the time they spend. The number of my questions may seem like I'm waiting for ready-made solutions, but I just don't understand the syntax of powerapps, so far I've used VisualBasic in excel macros and it takes me a while to switch to powerapps.