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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Global variable not co...
Power Apps
Unanswered

Global variable not correctly passing to forms

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am trying to do something very simple with the Set function. I am setting a global variable called SelectedRecord to a Record in a gallery and then setting the Item property of an edit form to SelectedRecord. I have 2 galleries and when the user selects the record it sets the variable to the selected record. The galleries use the same edit form when selected.

 

It works as intended on the first gallery but on the second, the variable doesn't seem to update to the new selected record. It is updating the fields in the form to the last selected record from the first gallery. Any ideas or is it just a bug?

 

Here is the code I am using:

 

Set(SelectedRecord, ThisItem); EditForm(TitleForm); EditForm(SeeForm); EditForm(EngageForm); EditForm(ChooseForm); EditForm(AchieveForm); Navigate(ChangeEditScreen, None)

 

Categories:
  • v-micsh-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

     

    I think the issue here should be mostly related with the form control.

    To have the form control work normally, it would require the record under the item property of the form control is one of the records from the Data source table configured under the From data Source property.

    The structure of the record should match.

    Besides, please don't use  Thisitem, instead, swtich the formula as below:

     

    Set(SelectedRecord, gallery.Selected); 

    ThisItem could only be referenced within the form control.

    For more information about form control, please check:

    Understand data forms in Microsoft PowerApps

     

    Regards,

    Michael

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I agree that it should work. I changed my syntax to Gallery.Selected from ThisItem and it still has the same behavior.

     

    On the form that is displaying the wrong record i also have a label that outputs "SelectedRecord.Title"  and it produces the right title but the form has the wrong data. SelectedRecord is my global variable.

     

    The form that produces the wrong record under Items also has SelectedRecord.

     

    I'm lost for what to do now. Do I need to reset my forms before I display them? Right now I am only using EditForm(Form).

     

    Maybe I wasn't super clear. I have to galleries that are subset of the same data.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard