cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Meneghino
Level 10

New Select() function: we can now reuse code!

The new Select() function from version 2.0.702 allows you to press/click another control from the same screen or container!

More details here

 

10 REPLIES 10
Anonymous
Not applicable

Re: New Select() function: we can now reuse code!

That is a great new function!

However, I am most existed about the autosave on Web Client which was not mentioned and it seems that the web client became a lot more stable I do not get any Your Session Has Ended messages like I used to!

Community Support Team
Community Support Team

Re: New Select() function: we can now reuse code!

Hi @Meneghino,

 

Thanks for your sharing, I found this function really useful. Let's hope that it could be more powerful in the future.

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
annashetty
Level: Power Up

Re: New Select() function: we can now reuse code!

Thank you very much for your expertise. I will keep the single app and work with your clever solution Putlocker

Super User
Super User

Re: New Select() function: we can now reuse code!

If there any way to pass parameters? To be really useable that would be awesome!

 

Is there any MS documentation on this? I can't find any documentation at all, only this thread.

Meneghino
Level 10

Re: New Select() function: we can now reuse code!

Hi @BitLord69

Documentation is an issue with PowerApps.

To pass parameters, you can just use context or global variables.  Therefore you can update the context or set the variable before you call the Select()

Super User
Super User

Re: New Select() function: we can now reuse code!

Thanks for your comment, @Meneghino!

 

I did just that, and it works fine. It's a bit unsafe though since PA can't check if the variable is set or not. Having a parameter, PA can flag that it's missing or being of the wrong type. I'm happy MS have taken this first step though, made my code much nicer.

 

Documentation is always an issue, in every organisation! It would be nice to read that a new feature exists to begin with and how it works, with examples; that speeds up the development process.

austinsense
Level: Powered On

Re: New Select() function: we can now reuse code!

My intent is for the user to press an icon button instead of clicking on the camera control.

 

I have a camera control (Camera_01) that has OnSelect = ClearCollect(PhotoCollection, Camera_01.Photo). This control works great, and I have an image gallery that shows the photo taken. I would like to create an icon that mimics the OnSelect property of the Camera, so for the Icon I set OnSelect = Select(Camera_01). With this setup, nothing happens when I click the icon. What am I doing wrong?

Austin Senseman
Partner, PowerPivotPro
tmtm
Level: Powered On

Re: New Select() function: we can now reuse code!

This is a great feature. But it seams that "Select" is nonblocking only - is there any way to make the "call" blocking?

 

Documentation is missing so this might be useful for other (I was quite surprise and it took me some time to debug and understand why following code does not work).

 

LabelXY is Label

LabelXY.text = "Work in progress, please wait"

LabelXY.visible = workInProgressVisible

 

Then 3 buttons. ButtonA, ButtonB, ButtonC.

 

In ButtonA.OnSelect I have this code:

 

UpdateContext({workInProgressVisible:true});

Select(ButtonB);

Select(ButtonC);

UpdateContext({workInProgressVisible:false)

 

ButtonB and ButtonC do some calculation, so it takes like 20s for ButtonB and 10s for ButtonC to finish their tasks. And ButtonC expect some parameters from ButtonB work (passed via context variable)

 

My expectation was that the Label "work in progress" visibility will be set to true, then the ButtonB will do the action then the ButtonC will do the action and last the Label "work in progress" visibility will be set to false.

The reality is that the Label is not visible at all - the UpdateContext({workInProgressVisible:false) is run almost immediately after UpdateContext({workInProgressVisible:true});

Also Select(ButtonC) finished the caluclation before Select(ButtonB), so they were performing the calculation in paralel and not in serial way as I need.

 

Obviously a workaround is to put all the calculation into ButtonA.OnSelect() only, that works ok, but the beauty of the code reuse is gone :/

 

Anonymous
Not applicable

Re: New Select() function: we can now reuse code!


@tmtm wrote:

This is a great feature. But it seams that "Select" is nonblocking only - is there any way to make the "call" blocking?

 

Documentation is missing so this might be useful for other (I was quite surprise and it took me some time to debug and understand why following code does not work).

 

LabelXY is Label

LabelXY.text = "Work in progress, please wait"

LabelXY.visible = workInProgressVisible

 

Then 3 buttons. ButtonA, ButtonB, ButtonC.

 

In ButtonA.OnSelect I have this code:

 

UpdateContext({workInProgressVisible:true});

Select(ButtonB);

Select(ButtonC);

UpdateContext({workInProgressVisible:false)

 

ButtonB and ButtonC do some calculation, so it takes like 20s for ButtonB and 10s for ButtonC to finish their tasks. And ButtonC expect some parameters from ButtonB work (passed via context variable)

 

My expectation was that the Label "work in progress" visibility will be set to true, then the ButtonB will do the action then the ButtonC will do the action and last the Label "work in progress" visibility will be set to false.

The reality is that the Label is not visible at all - the UpdateContext({workInProgressVisible:false) is run almost immediately after UpdateContext({workInProgressVisible:true});

Also Select(ButtonC) finished the caluclation before Select(ButtonB), so they were performing the calculation in paralel and not in serial way as I need.

 

Obviously a workaround is to put all the calculation into ButtonA.OnSelect() only, that works ok, but the beauty of the code reuse is gone :/

 


I was bitten by this side effect (non-blocking call) in my code while trying to reuse code. Hope PA team addresses this issue. I already reported this issue.