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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How do I properly use ...
Power Apps
Unanswered

How do I properly use StartScreen ?

(1) ShareShare
ReportReport
Posted on by 15

Hi All 

 

I have read that OnStart and especially its use with the Navigate function is set to be deprecated and in its place will be StartScreen. I have code on my OnStart that works just fine, however I have no clue how to Set it up on StartScreen - below is my code: 

 

/ Obtain username and email of the logged-in user
Set(varLoggedInUser, User());

// Find the user with a matching email in the App Users list
With(
 {wUserRecord: LookUp(LSS_TRACKER, Uzer.Email=varLoggedInUser.Email)},
 Set(varUser, wUserRecord.FullName);
 Set(varRole, wUserRecord.LSSRole.Value);
 Set (varID, wUserRecord.ID);
 Set(CurrentUserFirstName, Office365Users.MyProfile().GivenName);
 Set(CurrentUserFullName, Office365Users.MyProfile().GivenName & " " & Office365Users.MyProfile().Surname) 
);

// If matching user is not found, insert a new user into the list with the role User
If(IsBlank(varRole),
 With(
 {wUserRecord:
 Patch(
 LSS_TRACKER,
 Defaults(LSS_TRACKER),
 {
 LSSPersonName: CurrentUserFullName, 
 Uzer: {
 '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
 Claims:"i:0#.f|membership|"& varLoggedInUser.Email,
 Department: "",
 DisplayName: varLoggedInUser.FullName,
 Email: varLoggedInUser.Email,
 JobTitle: "",
 Picture: ""
 }
 
 }
 )
 },
 Set(varUser, wUserRecord.FullName);
 Set(varRole, wUserRecord.LSSRole.Value);
 Navigate(NewUser,ScreenTransition.Cover);
 ),
 Navigate(AdminView,ScreenTransition.Fade);
);

 

How would I adapt this to use StartScreen? I appreciate any and all suggestions!

Categories:
I have the same question (0)
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @Ali1 

     

    StartScreen and OnStart work independently. Microsoft needs to revisit this purpose. As of now, not much use when you have some dependent information or logic on OnStart

     

    • App.OnStart to collect the data (Collect, Lookup, Set)
    • App.StartScreen - Set the Start screen. We can't rely on variables or collections from App.OnStart since both are independent

     

    Both are independent events, so we can't reference any variable or collection in App.StartScreen for condition-based navigation.

     

    So for navigation, we have to get the data from the source to make conditional in StartScreen

     

    StalinPonnusamy_0-1637698303486.png

     

    If you don't want to modify your code, you could turn on this setting:

    StalinPonnusamy_1-1637698315362.png

     


    Thanks,
    Stalin - Learn To Illuminate

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Ali1 To clear the air, Navigate is not deprecated. StartScreen is a declarative alternative to using Navigate in the OnStart of the App. You can very well continue to use Navigate in other parts of the App. The advantage of using StartScreen is to speed up the loading of the first (start) screen. Which means, the first screen will load without waiting for the execution of all the code in the OnStart to finish. This is good for loading speed whereas it can be bad if you have some logic that has to be performed before the first screen is loaded (which I think is your case).

    So, you have to device a way that all the necessary code is executed before your first screen is loaded. You are checking if the current user exists or not. If the user exists, you are taking them to the AdminView Screen. If not, you are creating the user and then taking them to the NewUser Screen.

    You can remove all the code in the OnStart and place this code in the StartScreen,

    If(IsBlank(LookUp(LSS_TRACKER, Uzer.Email=User().Email)),
     Navigate(NewUser,ScreenTransition.Cover),
     Navigate(AdminView,ScreenTransition.Fade)
    )

     

    Then in the OnVisible of the NewUser Screen, do all the logic for creating the new user etc.,

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard