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 / Using Set to define a ...
Power Apps
Unanswered

Using Set to define a variable from multiple locations

(0) ShareShare
ReportReport
Posted on by 119

Hi all,

 

I am trying to set a record to a variable from multiple controls and receiving an incompatibility error, even though the two definitions are both records.

 

I am building an app that allows users to search a collection to find a needed document, select it, and bring it up in the PDF viewer. When a user selects an item from the gallery, it sets varItem as searchGallery.Selected, then navigates to the search result screen. OnVisible, the search result screen runs a PowerAutomate flow to retrieve the PDF data of the selected item using varItem.

 

Search Result Screen

powerUser1611_0-1644939550252.png

Selected Item screen

powerUser1611_1-1644939631994.png

 

My issue is that I don't simply have one gallery that users can select to set varItem, but 2. When a user selects the "Show Related" button on the search result screen, it brings up a gallery of related documents they can also launch. This has the same syntax as the original gallery, Set(varItem, searchGallery.Selected), however it produces an error saying my variable types are mismatched:

 

Related Documents Gallery

powerUser1611_3-1644939915210.png

 

I know that the only two definitions of varItem define it as a record. Is there a way to define a variable from multiple locations or another workaround? Any guidance would be appreciated.

Thanks!

 

 

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @powerUser1611 

    The schema of the records is what is important - not just that they are records.  PowerApps will throw an incompatible type error if you try to set a variable to one record with a specific schema, and then to another record that has a different schema.

    So, no, you cannot do that in this case.  

    You can alter the schema with datashaping functions in PowerApps on your Gallery so that the gallery columns/schema are identical in all the places you want to set a variable.  Then you will have no issues with it.

     

    I hope this is helpful for you.

  • powerUser1611 Profile Picture
    119 on at

    Yes, you are exactly right.

    Instead of having two unique galleries, I copied the original and reused it for the second one. This aligned all of the data points within the record. I had no idea that using Set wrote columns from the datacard into the record. I also realized that in one gallery I had Set(varItem, ThisItem) and Set(varItem, searchGallery.Selected) in the other, which also gave me the incompatibility error. After aligning the two galleries and Sets, it is working as intended. 

     

    Thanks!

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 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard