HI Everyone,
In the form below the user creates a inventory from a template (about 700 records). The record from the template are copied up the to device locally into a collection Originally, I had the user filling in the numbers using a tablet and posting each record as the user filled in "Qty on Hand". I soon learned this caused time delays on each post and caused it loose focus. This made the user experience very difficult.
To correct this thought I would save all posts to the collection till the user finished the inventory. Then iterate through the gallery and post each value for the inventory count. To do this I thought would first create a test. The test would iterate through all records and assign "Qty on Hand" a value of 5
Here is my test code:
ForAll(
Gallery2_11.AllItems,
Patch(
TempInvtry,
LookUp(
TempInvtry,
Text(ID) = Title2_11.Text // Gallery ID colomn
),
{Qty: 5} //"Qty on Hand"
)
);
To my surprise it did not iterate through Allitems in gallery. You can see by the above screen shot that it only appeared change random records. If scroll down and press the test button again I get more records changed.
Any Ideas why Allitems is not getting all records?
Thanks
As an opening question: if you load your Gallery into a collection does it include all of the items? Put this code in a random label to check. Does this number match the rows in your Gallery?
CountRows(Gallery2_11.AllItems)
The reason I ask is sometimes gallery.allitems does not load all the rows because galleries only retrieve data from the datasource as needed.
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
Just to clarify:
CountRows(Gallery2_11.AllItems) seems to work with no problems. Check the bottom right of the screen.
Thanks again,
Sorry replied to myself so this will show up twice... sorry for the confusion for future readers.
Just to clarify:
CountRows(Gallery2_11.AllItems) seems to work with no problems. Check the bottom right of the screen provided. In this example there were 561 records, not 700
Thanks again
@JasonF
Ok, now that weโve gotten the preliminary question out of the way can you tell me more about your LookUp?
The 2nd argument must compare something in Gallery1.AllItems to something in TempInv. Could you please tell me what is being compared in your function?
LookUp(
TempInvtry,
Text(ID) = Title2_11.Text
)
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
Ok, in anticipation of some additional question I will give some more details:
First Text2_11,text refers to the ID column on the above screen shot. Once the user selects a template (Lower Left) and presses the "Create Inventory" button I use a ForAll function along with a collection to populate that template into a inventory worksheet that is local to the device. This process looks something like this
CREATE INVENTORY
ClearCollect(
TempInvtry,
{
Category1: "",
ID: 0,
ItemNO: "",
UnitQty: 0,
Descrition: "",
Qty: 0,
UnitCost: 0,
PurchaseCst: 0,
InRptNo: "",
UnitType: ""
}
);
ForAll(
'Template Details',
If(
crdf5_TemplateNo.TemplateNo = TempNo,
Patch(
TempInvtry,
Defaults(TempInvtry),
{
Category1: Text(crdf5_Category.Category),
InRptNo: DataCardValue4_4.Text,
Qty: 0,
ID: 'Version Number',
ItemNO: Text(crdf5_ItemNo.'Item No'),
UnitCost: crdf5_Units.'Unit Cost Cal',
Descrition: crdf5_itemdescription,
PurchaseCst: crdf5_purchasecost,
UnitType: crdf5_Units.'Unit Type Cal',
UnitQty: crdf5_UnitQtyCal.'Unit Qty'
}
)
)
)
This searches through the template table and populates a collection based on the users choice of template.
(I know that a Filter('Template Details', crdf5_TemplateNo.TemplateNo = TempNo) on the ForAll statement would make more sense, but using this method breaks all the lookup fields (don't know why and maybe something for another discussion). So I used the IF statement and this seem to work, but a little slower.
The next thing to know is I populate the collections "ID" field with the 'Version No". This just appeared to be unique number and severed my purpose to have each record in the collection have a unique ID (please keep in mind I am relatively new user and probably a better way to do this).
Which brings me back to my problem of not wanting to post each change until the user is finished the inventory. Which led me to thinking of running a ForAll function on the Gallery, Which led me to our problem. Additionally, I have done some more test on this by removing filters and sorts on the gallery with same results. I cannot even see a pattern to what records are being change to Qty=5, it appears random. It does not make any difference to scroll through the whole gallery to bottom. If scroll to one part of gallery and run the test, it captures a bunch more records. If you do not move and run the test again there is not additional records changed, however if you scroll the gallery just a few records and then run the test you get addition records being changed to Qty=5. If you randomly scroll up and down the gallery a few time (Maybe 10x) you eventually change all the records. Very puzzling.
Thanks again for the help,
@JasonF
I do not necessarily know why the Gallery is not working for you... however, we can try a slightly different approach that does not involve Gallery.AllItems.
My idea is to put this code in the OnChange property of your TextInput_QtyOnHand. Every time the Qty On Hand is updated by the record-keeper it puts the inventory level changes into a temporary collection called colInvQtyOnHand.
Set(currentRecord, LookUp(colInvQtyOnHand, ID=ThisItem.ID));
If(IsBlank(currentRecord),
Patch(colInvQtyOnHand, Defaults(colInvQtyOnHand), {ID: ThisItem.ID, QtyOnHand: ThisItem.TextInput_QtyOnHand.Text}),
Patch(colInvQtyOnHand, currentRecord, {ID: ThisItem.ID, QtyOnHand: ThisItem.TextInput_QtyOnHand.Text})
)
Then when the 'Post Inventory' button gets clicked you could run this code. Essentially, I'm hoping we can bypass this by removing the any references to the gallery itself.
ForAll(
colInvQtyOnHand,
Patch(
TempInvtry,
LookUp(TempInvtry, ID=colInvQtyOnHand[@ID]),
{Qty: colInvQtyOnHand[@QtyOnHand]}
)
);
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
Hi @JasonF ,
Actually, I agree with @mdevaney .
I could not find where's your problem precisely.
Your formula looks good.
Do you have any delegation warning?
Maybe you could try this:
change the delegation limit to 2000.
This limit will make your app perform not good neither.
Best regards,
Thanks for the reply,
I made the change you referenced, with no change in results. I did not expect a change as we are dealing with a collection and my understanding is collections fall outside the delegation problems. Anyway, I am going to try one more test on CDS data sets directly and a gallery and see if the results are the same.
I will keep you posted.
Regards.
User | Count |
---|---|
224 | |
100 | |
94 | |
57 | |
31 |
User | Count |
---|---|
281 | |
114 | |
110 | |
63 | |
57 |