In my current set up, I am working with a large On-Premise Database data set; TRUCKLOG : 40,000 records. I display a limited amount of this data in a gallery, TRUCKGALLERY, based on filtered criteria where LOADS<>INVOICED. From here, I have users "form fill" other information with some editable TEXT INPUTS. The user then clicks the UPDATE button, which saves all updated information by creating a collection TRUCKCOLLECTION, and then click the SUBMIT button, which patches everything through to back to the database.
Problem: The above works fine, UNTIL my TRUCKGALLERY has more than 15 records. It takes forever because it is patching the whole TRUCKCOLLECTION, even if there was no change in the record. I was wondering of there is any way to identify and ONLY collect records that have been changed in the TRUCKGALLERY.
Attempts: I added a label "RECORDCHANGE", and set this to "N". I am currently trying to change it to "Y" whenever there is a change to any of the editable fields. This is so that when the user clicks UPDATE, the app can just collect the TRUCKGALLERY where RECORDCHANGE = "Y". I have not been successful in doing this, because can not find anything that changes RECORDCHANGE to "Y". The closest I have reached with no errors was by adding 'CHANGERECORD'.Text = "Y" , to the OnChange field of the Editable Text Inputs, but it does absolutely nothing.
Is there another property that can successfully change RECORDCHANGE to "Y"?
Is there perhaps another way to identify and ONLY collect records that have been changed in the TRUCKGALLERY?
If your text values are in an edit form, you can patch back just the form. This is much quicker.(Code Below).
If you're not using a form, you can still use the code below but your patch will look different where the forms are listed. You would just have your fields.
I think you could probable benefit from reading up on the patch command.
Patch function - Power Apps | Microsoft Docs
PowerApps Patch Function with examples - SPGuides
Patch(
'TRUCKLOG',
Defaults('TRUCKLOG'),
Form1.Updates,
Form4.Updates,
Form5.Updates
)
Ok, so this somewhat works. I didn't use any forms. I do not believe I can. I need to show my information in somewhat of a Excel Base View.
It patches directly to the database with the following:
ForAll(TRUCKGALLERY.AllItems,
(Patch(TRUCKLOG, ThisRecord,{Material: RPTJOBDET_MAT.Text, ETC.} )))
However it is still taking long if my Gallery displays 15+ Rows. I would prefer to collect only records that have been updated and then patch those through.
There's probably better ways to do this, but my initial thought is you need something that shows that the record has been modified and then you patch only those.
You could add a checkbox that the user will check and then only patch records where the box is checked.
If you don't want to have the user check the box, you can add some logic to evaluate if the record in the gallery has been modified and check the box automatically.
Then you would modify your patch to only patch records where the box is checked.
That is exactly what I am trying to do.
From Initial Post:
" I was wondering of there is any way to identify and ONLY collect records that have been changed in the TRUCKGALLERY.
Attempts: I added a label "RECORDCHANGE", and set this to "N". I am currently trying to change it to "Y" whenever there is a change to any of the editable fields. This is so that when the user clicks UPDATE, the app can just collect the TRUCKGALLERY where RECORDCHANGE = "Y". I have not been successful in doing this, because can not find anything that changes RECORDCHANGE to "Y". The closest I have reached with no errors was by adding 'CHANGERECORD'.Text = "Y" , to the OnChange field of the Editable Text Inputs, but it does absolutely nothing. "
The logic is what I currently need help with. I would like to not put the identification process in the hands of the user. I foresee a bunch of user errors with that. I also could not get the check box to work either. Do you have the proper code for that? Again I added 'CHANGERECORD'.Text = "Y" ('.Value = True' for the Check Box) , to the OnChange field of the Editable Text Inputs. It showed no errors but it did absolutely nothing.
There's a whole bunch of ways to do this, and I'm sure one is better than the others.
We might be overthinking this. Why not just add the patch to the OnChange for the fields you want to keep track of?
Patch(
TRUCKLOG,
ThisItem,
{
HAULNUM: haultextbox.text
}
))
Whenever you change the value, it patches that record back.
This was one of my first designs; it was very glitchy. After I entered my first field, I would tab over to start filling other fields, and it would reset my inputs and and pull me out of focus. I imagine this was the writing that was taking place, and the data source refreshing after. I would have to click back into the fields and retype everything it reset, ultimately waiting close to 3 to 4 full seconds after every input. With the amount of data being entered, that can't happen.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
192 | |
69 | |
50 | |
38 | |
29 |
User | Count |
---|---|
245 | |
112 | |
92 | |
91 | |
71 |