cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Flyingfishnm
Helper I
Helper I

Local, Global Variables and DataTable

Hi

 

I'm working on my second powerapps screen and i'm struggling to work out the best way to create/use variables either global or local. I've looked for examples but have not found anything so I thought i'd ask and hopefully someone will point me in the right direction! 😀

So, 1) to create a local variable do I use an hidden label text control? 2) how do i create a global variable not using a button? finally, can i manually populate a DataTable? i.e. not attaching it to database/sharepoint list?

 

Thanks for any help! 👍

dj

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @Flyingfishnm ,

 

1\ No. 

 

2\ If you want to create variables automatically, please try the following ways.

(1) Use app's OnStart property. Automatically create a variable when the app is opened

For example: you could use this formula on OnStart property

Set(Thevar,"Test")

(2) Use screen's OnVisible property.Automatically create variables when a specific screen is visible.

For example: you could use this formula on OnVisible property

Set(Thevar,"Test")

 

3\ You could create a collection in powerapps.

For example: Add a button control and set its onselect property to:

ClearCollect(Col,{Column1:"A",Column2:"B"},{Column1:"C",Column2:"D"})

v-xiaochen-msft_0-1617759350994.png

 

Of course, you could also use onstart property or onvisible property instead of button control's onselect property.

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

 

View solution in original post

2 REPLIES 2
v-xiaochen-msft
Community Support
Community Support

Hi @Flyingfishnm ,

 

1\ No. 

 

2\ If you want to create variables automatically, please try the following ways.

(1) Use app's OnStart property. Automatically create a variable when the app is opened

For example: you could use this formula on OnStart property

Set(Thevar,"Test")

(2) Use screen's OnVisible property.Automatically create variables when a specific screen is visible.

For example: you could use this formula on OnVisible property

Set(Thevar,"Test")

 

3\ You could create a collection in powerapps.

For example: Add a button control and set its onselect property to:

ClearCollect(Col,{Column1:"A",Column2:"B"},{Column1:"C",Column2:"D"})

v-xiaochen-msft_0-1617759350994.png

 

Of course, you could also use onstart property or onvisible property instead of button control's onselect property.

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

 

...thank you so much! 👍 😊

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Users online (4,806)