I am creating an inventory tracker. I have a SharePoint list with the inventories that are in a gallery with a checkbox next to each item. The user selects which items they would like to update, hits update, and a collection (checkedItems) is made with all of the items that were checked. The user then puts in how many they would like to Add or Take, and that number is used to alter the SharePoint list's item quantity. Screenshots are below.
The issue I am having is that the formula in the LookUp function is just not working. I can't seem to find the right syntax to compare the datasource's item IDs to the collection's to find the right record to Patch. Here is my code for the Add button:
ForAll(checkedItems,Patch('Inventory Tracking - TESTING',LookUp('Inventory Tracking - TESTING',ID=checkedItems.ID),{Quantity:Quantity+TextInput2_3})) ; Set(_popup,false) ; Set(isChecked,false) ; Set(isChecked,true) ; Clear(checkedItems)
**Screen 1
**Collection of checked items
**Add button in context of app
Any thoughts are welcome!
Solved! Go to Solution.
You don't need a checked collection for this...you already have one - the Gallery!
Please consider changing your Formula to the following:
Patch('Inventory Tracking - TESTING',
ForAll(
Filter(yourGallery.AllItems, yourCheckBox.Value) As _item,
{ID: _item.ID,
Quantity: _item.Quantity + Value(TextInput2_3.Text)
}
)
);
Set(_popup,false);
Set(isChecked,false);
Set(isChecked,true);
Substitute the name of your Gallery and checkbox in the gallery in the above formula.
I hope this is helpful for you.
You don't need a checked collection for this...you already have one - the Gallery!
Please consider changing your Formula to the following:
Patch('Inventory Tracking - TESTING',
ForAll(
Filter(yourGallery.AllItems, yourCheckBox.Value) As _item,
{ID: _item.ID,
Quantity: _item.Quantity + Value(TextInput2_3.Text)
}
)
);
Set(_popup,false);
Set(isChecked,false);
Set(isChecked,true);
Substitute the name of your Gallery and checkbox in the gallery in the above formula.
I hope this is helpful for you.
You are a wizard! Worked flawlessly! Thank you so much!
Another question. Say I wanted to put the Add and Take buttons on the main gallery screen and the update button on the pop up window. I tried roughly the same code, but now its updating every item checked with the first text input box value.
If(_addPressed=true,Patch('Inventory Tracking - TESTING',
ForAll(
Filter(Gallery2.AllItems, Checkbox2.Value) As _item,
{ID: _item.ID,
Quantity: _item.Quantity + Value(TextInput2_3.Text)
}
)
),Patch('Inventory Tracking - TESTING',
ForAll(
Filter(Gallery2.AllItems, Checkbox2.Value) As _item,
{ID: _item.ID,
Quantity: _item.Quantity - Value(TextInput2_3.Text)
}
)
)) ;
Any thoughts?
The pressed property is only while the button is pressed (i.e. clicked) it will not maintain that state.
You need to look at another control, like a checkbox or a toggle to maintain the state of the press. You can make a toggle look like a button and act like a "pressed - true" or "not pressed - false" control.
Secret sauce:
1) Add a Checkbox control
2) Set the Checkbox Size to 0
3) Set the Fill to : If(Self.Value, Blue, LightBlue) (choose your own colors)
4) Set the HoverFill to : Self.Fill
5) Set the HoverColor to: Self.Color
6) Set the Color to: If(Self.Value, White, Black)
NOW...you have another toggle in your gallery and you can use that in your formula:
Patch('Inventory Tracking - TESTING',
ForAll(
Filter(Gallery2.AllItems, Checkbox2.Value) As _item,
{ID: _item.ID,
Quantity: _item.Quantity +
(Value(TextInput2_3.Text) * If(yourNewToggleButton.Value, 1, -1))
}
)
)
I don't think I was very clear in my second question.
I want to swap the positions of the Add & Take buttons and the Update button.
The user will check the boxes of items he/she wants to update, then selects Add or Take, depending on what they're doing. Then, they enter the values and hit update. Depending on what they hit first (Add or Take) adjusts the quantity as such. Screenshots are below.
It is updating both items with only the first text box. Not sure why.
Let me know your thoughts!
User | Count |
---|---|
124 | |
87 | |
86 | |
75 | |
69 |
User | Count |
---|---|
214 | |
181 | |
139 | |
96 | |
83 |