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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Issue with 'reading' g...
Power Apps
Answered

Issue with 'reading' global variable with OnVisible of secondary start screen.

(0) ShareShare
ReportReport
Posted on by 62

I have a 3 screen app and have setup deep linking to the "third screen" based on a URL parameter. Pretty reliably (near 100% of the time) if a user utilizes the deeplink for their "first access" to the app, the OnVisible attribute for the third screen reads the global variable set by App OnStart as blank. However, I've added a debug text box to the screen and it 'clearly' shows the Global Variable value I expect. If I add a button to the screen that basically re-runs the code in OnVisibile everything functions as I expect. 

 

The app is backed by a Sharepoint List if this matters.

The code that I think matters is:

App: OnStart:

 

 

...
 If (Param("TargetScreen") = "Edit", 
 Set(SelectedItemID, Value(Param("NCRID")))
)

 

 

App: StartScreen

 

If (Param("TargetScreen") = "Edit", 
 NCREntryScreen,
 Browse_All )

 

 

NCREntryScreen: Onvisible

 

If(IsBlank(SelectedItemID),
 // We are creating a new NCR
 UpdateContext({CurrentNCRID: ""}),
 // We are working with an existing NCR
 UpdateContext({CurrentNCRID: 
 LookUp([@NCRs],
 ID = SelectedItemID,
 Title
 )
 }
 )
)

 

 

My Diagonistic Text Label: Text value is:

 

Concatenate("SelectedItemID: ", SelectedItemID, " NCRID: ", CurrentNCRID)

 

 

Re-try button: OnSelect

 

If(IsBlank(SelectedItemID),
 UpdateContext({CurrentNCRID:First(AdHocNCRID).Title}),
 UpdateContext({CurrentNCRID: 
 LookUp([@NCRs],
 ID = SelectedItemID,
 Title
 )
 }
 )
)

 

 

 

If I access the app with a url like the one below:

https://apps.powerapps.com/play/<APPID>?NCRID=542&TargetScreen=Edit

I am correctly routed to the desired screen, but the Text Label value shows: "SelectedItemID: 542 NCRID: "

Usually if I go to re-paste the URL in the browser it will render correctly like this: "SelectedItemID: 542 NCRID: 10396", right at the moment as I'm posting this, it's not behaving like this, but I'm not sure if my testing broke a piece of the code.

 

Is this because OnVisible is running before something's getting fully set? Would appreciate any insight.

 

 

Categories:
I have the same question (0)
  • Verified answer
    BCBuizer Profile Picture
    22,654 Super User 2026 Season 1 on at

    Hi @jnickell ,

     

    I think you have "Use non-blocking OnStart rule" turned on in the Upcoming features: 

    BCBuizer_0-1706043814413.png

     

    With this enables it can be that your CurrentNRID variable is populated before Selecteditem was, causing it to be blank.

     

    I'd try turning this off to confirm and as a quick fix.

     

    Ultimately, however, I would reconsider using two variables. I feel that using a single global variable would give you all you need, reduce complexity and take care of issues like these.

  • WarrenBelz Profile Picture
    154,906 Most Valuable Professional on at

    Hi @jnickell ,

    The issue here I believe is that StartScreen runs before OnStart. The easiest solution is to put the OnStart code you have posted OnVisible of the relevant screen and it will work fine.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • jcnickell Profile Picture
    62 on at

    I didn't know I had the non-blocking piece on, but I did. 
    RE: the two variables, I made this app a couple of years ago and I think at the time Context Variables were needed for some piece of what I was doing in the app, though at this point I can't say for sure. 

    I'll test out disabling that rule tomorrow. 

  • jcnickell Profile Picture
    62 on at

    I'll give this a shot too if the OnStart rule doesn't give me a workaround

  • jcnickell Profile Picture
    62 on at

    @BCBuizer Disabling the async app start seems to address the issue. I'll take this as the solution. Didn't realize that was a setting, thank you for brining it to my attention.

    @WarrenBelz Thanks for your guidance as well. I didn't try that approach but it seems like it could work, but would wind up duplicating code that I'd rather not for now. 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 528

#2
WarrenBelz Profile Picture

WarrenBelz 426 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 306

Last 30 days Overall leaderboard