web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Getting error when usi...
Power Apps
Unanswered

Getting error when using record created from gallery.Selected

(0) ShareShare
ReportReport
Posted on by 29

Hi Everyone,

 

I am noticing a weird behaviour in PowerApps.

 

Basically I have 2 screens in my PowerApps (Screen1 and Screen2). I have a flexible gallery (Gallery1) in Screen1 where I am displaying some records, I have used function "Navigate('Screen2',Fade,{recordValue:Gallery1.Selected});" OnSelect of Gallery1. Values from recordValue record are being used in Screen2, which also has a flexible gallery.

 

So when I edit the app, I get the error at all places of Screen2 where I have a reference of recordValue, however if I comment/uncomment my above function ("Navigate('Screen2',Fade,{recordValue:Gallery1.Selected});"), all errors get resolved.

 

Can someone let me know why I have been getting this weird behaviour of formulas.

 

Thanks,

Ankur

Categories:
I have the same question (0)
  • Roser Profile Picture
    24 on at

    Is there a description for the error. It colud be, that you define the variable in two different places with two different data types.

  • ankurjain30 Profile Picture
    29 on at

    @Roser When I comment/un-comment the OnSelect function, all the errors get resolved. I don't think there is an issue of a variable with different data type. ( I get 50+ errors)

  • AmirBakht Profile Picture
    262 on at

    I have faced similar problem. The issue was record type. I believe PowerApp builds the record type with some logic when it is updated in multiple locations and when it does not match the rest of the places the record is being updated, it throws the error. By commenting some code, the record type is picked from one source and un-commenting the code adheres it to the record type being set now. 

     

    I was facing this issue because of Patch being used to update the record. Its not ideal but I did the following,

    • Restructured my record so that I do not need to use Patch
    • In some places where the record was a small structure, I used Set and set the full record value rather than Patch it
    • I put my update options behind a button click and hid the button. Wherever I needed to make an update, I'd call Select(<button>) to make the update. Makes it easier to manage the updates

    The comment un-comment works, but once your solution starts to get bigger, it's going to cause you more and more issues. For me, I avoid Patch to update a record. UpdateIf also serves the purpose in most cases.

  • ankurjain30 Profile Picture
    29 on at

    Hi @AmirBakht ,

    Thank you for your response.

    However I am using whole record in my next screen.

    For eg. whenever we use a gallery.Selected, generated record contains all the control fields or label values, as well as record values from the collection that is being used as a data source for the gallery.

     

    What I noticed, at first instance when I get the error, record doesn't contain values of the data source but it holds values of the controls/labels only. However when I do comment/un-comment, it contains all the values as required.

     

    Regards,

    Ankur

  • AmirBakht Profile Picture
    262 on at

    I'd suggest checking the following,

    • When the page is loaded, check the record to see what it contains and if it is not correct, load some default values on page load. That way, it will know what data to expect
    • Wherever you are loading data into the record, try loading them with formatting, for example Text, DateTimeValue, etc.
    • I've faced some issues with DateTime before. If you have any of those naughty boys in there, comment them out to see if the problem persists. If so, that's where you need to put your efforts in
  • WarrenBelz Profile Picture
    153,127 Most Valuable Professional on at

    @ankurjain30 ,

    Just adding to @AmirBakht 's good work - use a Global Variable

    Set(recordValue,Gallery1.Selected);
    Navigate('Screen2',Fade)

    and all of the issues should go away.

  • ankurjain30 Profile Picture
    29 on at

    @WarrenBelz I have replaced context variable with global variable and also I have initiliazed it on App.OnStart. Now while editing the app, I am not getting the error. 

    However while running the published app, I do see a blank screen (Screen2) where I have used record values at OnVisible of Screen2.

     

  • WarrenBelz Profile Picture
    153,127 Most Valuable Professional on at

    @ankurjain30 ,

    You do not need to initialize it as this is done when the gallery item is selected. Also ensure the Context Variable no longer exists anywhere else as the value of this will override any Global Variable of the same name (you are better off changing the name).

    I only commented on the thread to suggest a better way of dealing with Variables not passing properly. I will leave you with @AmirBakht for the rest of the issue.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard