Hi
I went to bed yesterday reassured that I tested the following Power App to ensure it all works. Indeed, there are items in the gallery to prove it worked.
UpdateContext({lclCurrentFormRecord : Commun_EditForm.Updates});
Set(gblSelectedRecord, Patch(gblSelectedRecord,{Rec_Id: gblSelectedRecord.Rec_Id}, {Comment:lclCurrentFormRecord.Comment},{Update_Date_TM: Text(Now())} ));
This morning, is a different story : the Power App is freaky out about using a local (context) record field to replace global record field - it removed the code where I set global var to Parent.Selected in the gallery.
So in this unique requirement, do I use global vars both outside and inside the screen to avoid upsetting the Power App!
Solved! Go to Solution.
Yes, I encounter this quite often. Most of my apps have a small amount of variables and there is usually one that "carries" a current record I am working on.
I find that in places where I want to impact the variable in some way, say alter a column value, ex.
Set(glbCurrentRecord, Patch(glbCurrentRecord, {aColumn:"something"}))
That many times while typing in that formula, all of a sudden the whole app now has hundreds of errors. What is happening is that the formula editor is re-evaluating the schema and if I haven't completely typed out the name of a column (or I misspelled it accidentally), then it breaks the schema in the "mind" of the editor. Then the annoying, save, exit, reload.
I have learned that when I put these in, I usually will rename the variable (ex. glbCurrentRecord1) until I finish typing in the rest of the formula. Then if it is all without mistake, I change the variable name back. It helps some.
Thanks for the encouragement on the videos...I have a long backlog of videos to finish and need to carve out some time to publish more. I am so glad you learned a lot from the forms video...it definitely was a long one!
Yes, you can do this, but be very cautious about the schema of the variables. If your schema from the local to the global does not match in any way, then PowerApps will not like it.
Also, assigning record type variables is perfectly fine, but be aware that the PowerApps designer has to infer the signature from all of the places you set the variables. This can go wacky sometimes. Once the PowerApps designer has inferred an incorrect schema, the only way to force it to reevaluate the schema is to exit the designer and come back in. It's one of those things where you can make a slight change in an assignment of a variable in a formula and all of a sudden your app with 0 errors can now have hundreds of errors, and they are all related to that variable. There is nothing you can do to correct it except to exit and come back in.
I hope this is helpful for you.
Thanks for the advice. In this instance I have made all record vars global but as you say this maybe a schema issue , and so may still haunt me. I will keep keep calm and carry on testing.
Btw Pls keep posting your videos on YouTube , I really got to master forms, thanks to your 2.5 hour epic !
Yes, I encounter this quite often. Most of my apps have a small amount of variables and there is usually one that "carries" a current record I am working on.
I find that in places where I want to impact the variable in some way, say alter a column value, ex.
Set(glbCurrentRecord, Patch(glbCurrentRecord, {aColumn:"something"}))
That many times while typing in that formula, all of a sudden the whole app now has hundreds of errors. What is happening is that the formula editor is re-evaluating the schema and if I haven't completely typed out the name of a column (or I misspelled it accidentally), then it breaks the schema in the "mind" of the editor. Then the annoying, save, exit, reload.
I have learned that when I put these in, I usually will rename the variable (ex. glbCurrentRecord1) until I finish typing in the rest of the formula. Then if it is all without mistake, I change the variable name back. It helps some.
Thanks for the encouragement on the videos...I have a long backlog of videos to finish and need to carve out some time to publish more. I am so glad you learned a lot from the forms video...it definitely was a long one!
Turns out I wasn't quite there. Loaded up the Power App and this morning and the Edit form that is open by selected an item in the gallery is now broken.
this 'bug' may have been the source of my woes and not say using local vars to update the global selected record , the patch statement.
In that particular formula you are trying to set the global variable to the Selected item of your Gallery. If you are using that variable then in other places that rely on the signature/schema of that record to be based on the DataSource (ex. an EditForm), then you need to make sure it is identical.
The first place I look at would be the Items property of the gallery. If you are manipulating the schema of the Items in the Gallery (i.e. adding, removing or showing only certain columns, or grouping) then you will have a schema mismatch.
@RandyHayes
Thanks for reaching out. I was going to post an update, as the form is now broken again 😥. Of course this worked yesterday. I think the issue is I am sucessfully selecting the gallery item and going to the editform with the item ( set to a glb var). Then if I attempt to change the glb var by replacing it with a lookup of an existing record , then I see those lovely red indicators
Note global var is unique to this form and the gallery above. I have also removed the lcl vars that participate in the form submit or patch, so the error is strange.
I am having to finish for the day but will look at this issue over the weekend to see if I can post up any diagnostic details.
Sounds good...look it over and see. Definitely look at the Items property of the Gallery and also, you mention you set this to a LookUp...what is that looking like? Somewhere there is a schema mismatch that is causing the app to "weird out".
I think I have located the issue:
// Here I made the mistake of replacing the whole form record with the the global var
// populated by a LookUp
//Set(gblSelectedRecord, gblExistingRecord);
// replace any record columns incl the discuss text, before we display on the form
// so by removing the above line I can make the changes required hjere
Set(gblCommunSelectedRecord, Patch(gblExistingRecord,{Rec_Id: gblExistingRecord.Rec_Id}, {Discuss:gblCurrentFormRecord.Discuss}, {Update_Date: Text(Now())} ));
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
203 | |
47 | |
43 | |
40 | |
36 |
User | Count |
---|---|
289 | |
81 | |
81 | |
79 | |
71 |