cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Why we can not use Navigate() in OnVisible

In my app I have a screen which acts as a loading screen and verifies that information is retrieved correctly from the server. 

 

For example here is a very simplified version of the OnVisible:

 

UpdateContext({LoadingText:"Searching for your name..."});
Set(
    _UserProfile,
    Office365Users.MyProfile()
);
If(
    !IsBlank(_UserProfile),
    Navigate(MainMenu_Screen,None),
    UpdateContext({LoadingText:"Failed to load your profile. Please restart the App"})
)

Having this function I get red line under Navigate which reads like this:

 

 

Navigate cannot be used here since it would always navigate away from this screen.

1.png

 

This error makes no sence since it would always navigate only if the IF condition is true. Can this limitation be removed please?

 

Work around

There is a simple workaround with using a button or any other control with OnSelect property and calling the Select(YourButton) to execute the Navigate() function.

 

For example, add a button and change its OnSelect to:

Navigate(MainMenu_Screen,None)

Now in the OnVisible property change your code to this:

UpdateContext({LoadingText:"Searching for your name..."});
Set(
    _UserProfile,
    Office365Users.MyProfile()
);
If(
    !IsBlank(_UserProfile),
    Select(Button1),
    UpdateContext({LoadingText:"Failed to load your profile. Please restart the App"})
)

Now it works as intended but you had to create some extra controls.

 

11 REPLIES 11

 

Hi @HadynM

 

Thanks so much for the suggestion and that would be the natural reaction to reach that control and delete it. It could also be done via the left side navigation area by right clicking the control.

 

But my problem was that the control contained a very very very complicated OnSelect property which I slowly built up in two-three weeks' time, I just couldn't risk deleting it.

 

However, I found a way. I just disconnected my internet after the screen loaded. The control started populating the collections without internet, and kept trying. I reconnected for a few moments and cleared the onvisible property of the screen. Saved the app in the same second and the problem was gone.

 

Anyways, it is always a pleasure in speaking with professionals, especially when someone takes time to help you out. I am an accountant by the way and very new to powerapps, but I am in love with the community here.

 

Many many thanks.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (31,474)