I'm a newbie and this is my first post so apologies in advanced.
We have an issue with a set of fields within a gallery (which has a collection data source):
We have an issue whereby for each of the input text fields shown above we have to clicking twice on the field before we can enter in any data.
The “double” clicking action to set focus in one of the text inputs comes about we believe because the input text fields have an OnChange action:
If(!IsBlank(NameColInput.Text) && NameColInput.Text <> "" &&
!IsBlank(CompanyColInput.Text) && CompanyColInput.Text <> "" &&
!IsBlank(PositionColInput.Text) && PositionColInput.Text <> "",
We thought about moving the functionality for saving the entered collection data to the submit button at the end of the process.
This seemed like a better place for it anyway. However, we came across other issue with the Gallery.AllItems value being null.
What we thought about using on Submit was a ForAll loop to go through the Gallery.AllItems and patch the collection.
However, this didn’t work because the AllItems was always returning null (is this a bug?).
To get around the Allitems issue, we also thought about swapping in the collection and out for the Gallery.AllItems but you can’t loop through and update the same collection within a ForAll loop:
Notify("[" & IDColInput.Text & "]");
Patch(RecipientsCollection, LookUp(RecipientsCollection, IDCol = Value(IDColInput.Text)),
So we've hit a blank now and we don't know what to try next - does anyone have any ideas?
well, in general, any kind of self reference in onchange can cause such awkward behavior.
I would start by checking when the error disappears by removing parts of the function.
As soon as you find it the next step will be to check what and why cause the error and try to find another approach.
So, for example, I would delete OnChange action content. If it helps, then the question is whether it can be put elsewhere. Maybe you can give a label / warning that appears if these fields values are empty - so the checking operation would not happen in onchange action. Especially that the OnChange approach is imperative, and powerapps was created to work in declarative approach.
Thanks for the reply, I know that the Update() is causing the issue.
I did try and move the code out of the OnChange, that's what the error checking above it was for (by setting the varValidRow).
My plan was to check all varValidRow values where true. If they were, I would Update()/Patch() the record(s), otherwise I would show an error message.
What I couldn't figure out was how to do the Update outside of the Gallery, do you have any suggestions?
As I mentioned the Gallery.AllItems didn't work.
1. User a collection and just display it using gallery. So in that case you'll need to work on the collection, not gallery.
2. Instead If before Update you can run UpdateIf function
3. Nevetherelss a function ForlAll(Gallery.AllItems) should work properly anyway. Especially with Patch/Update in it. I use it quite frequently 🙂 Just make sure you reference to the proper items inside forall and patch function - sometimes I've got confused when the names where to similar to each other (control name, column name, record name)
Check out new user group experience and if you are a leader please create your group
Did you miss the call?? Check out the Power Apps Community Call here!
ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.