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

Community site session details

Session Id : a+YR30ku6t/rdD/qK07NoE
Power Apps - Building Power Apps
Answered

Using a global variable with a form

Like (0) ShareShare
ReportReport
Posted on 16 Feb 2021 10:04:32 by 716

Hello Power Apps Community,

Can you help please? I'm dreadful with variables, and need some assistance. This may get confusing. 

 

In a nutshell I want to pass a record in a gallery to a form, but... I already pass a record from another gallery into that form.

 

Here's the long explanation.

I have a screen Screen Search Employee which has a gallery galEmployee.

For the OnSelect property of galEmployee I have the below formula.

Set(
      gblEmployee,
      ThisItem
);
Navigate('Screen Edit Employee');
ViewForm(frmEditEmployee)

 

So this passes the record of the selected Employee record in the Employee gallery galEmployee by using the global variable gblEmployee to the screen Screen Edit Employee, which holds a form called frmEditEmployee. 

 

This is working perfectly. So I click an Employee record in the Employee gallery and on the other screen then details of that employee show on the form.

 

My request

I have another screen Screen Edit Company that has a form, which shows a Company record.

The Company table is the parent of the Employee table.

So 1 Company record can have many Employee records.

On this screen Screen Edit Company beneath the Company form I show all the related Employee records in a gallery galCompanyEmployee.

When a user clicks on a specific Employee record in the gallery, I pass them again to the Screen Edit Employee which holds the form called frmEditEmployee. So, the same as above.

I use this formula in the OnSelect property of a record in the gallery galCompanyEmployee:

 

Navigate('Screen Edit Employee');
ViewForm(frmEditEmployee);
 
But, when I'm landing on the form frmEditEmployee it is not showing the record I selected in the gallery galCompanyEmployee.
This, I think, is because I'm not passing/referencing a variable.
 
How can I call the global variable I already have gblEmployee? Or am I misunderstanding how global variables work.
 
Thanks very much,
Garry
  • CU01081947-0 Profile Picture
    716 on 16 Feb 2021 at 17:03:16
    Re: Using a global variable with a form

    Hello @VijayTailor,

    This worked perfectly. I didn't release I had to set the variable on both galleries. I've learnt something today!

    Thanks very much,

    Garry

  • Verified answer
    Vijay Tailor Profile Picture
    2,961 on 16 Feb 2021 at 13:23:56
    Re: Using a global variable with a form

    Hi @GarryPope ,

    Yes, You can set the Same variable in Both galleries, but if Gallary has the same source then you can use the Same form but both data sources are different then you need to use different from based on condition.

    Like - Source 1 - ID,Name column 
    and Source 2- also have the Same Column then you can use the Same form.

    but if Source 1  - Have ID,Name column 

    and Source 2 - have ID, Name,Other FIeld then you need to use different form.

  • CU01081947-0 Profile Picture
    716 on 16 Feb 2021 at 12:28:46
    Re: Using a global variable with a form

     

    Hello @VijayTailor

    Thanks so much for the swift reply. So I can set the same variable in both my galleries and pass them to a single form?

     

    Thanks very much,

    Garry

  • Vijay Tailor Profile Picture
    2,961 on 16 Feb 2021 at 10:42:43
    Re: Using a global variable with a form

    Hi @GarryPope ,

    You can use the variable you declared already.

    set this variable into the Items Property if you are using the Same source where your variable updated.
    See the reference below -  (Note - you can use global variable anywhere in the App.

    VijayTailor_0-1613472124074.png

     



    Thanks,

    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."-Vijay




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

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473

Loading complete