Hi All,
I'm receiving an error message when trying to reference a Context Variable on a screen within my app.
The Context Variable is being set as part of the "OnVisible" property within screenSuccess.
UpdateContext({ctxtReqID: frmNewRequest.LastSubmit.ID})
Pretty straightforward. The referenced form (frmNewRequest) is on the previous screen. Once submitted, the user is navigated to screenSuccess. Thus, the idea is to simply set ctxtReqID to the ID # of the request (BTW, this is being submitted to a SharePoint List).
At the top of screenSuccess is a header component; the HeaderText property has the following:
"Request #" & ctxtReqID & " has been submitted!"
However, the app is displaying an error message which states:
"Name isn't valid; 'ctxtReqID' isn't recognized"
If I update the HeaderText property to the following, it works fine:
"Request #" & frmNewRequest.LastSubmit.ID & " has been submitted!"
Obviously, there's no reason I couldn't simply use this instead of setting/referencing a Context Variable, but I'm still a bit mystified on why it wouldn't work through a Context Variable since it's being set (or, should be) to that same exact property of the Last Submit ID.
Thanks! I do understand that concept, and makes sense. I thought there was also a way to pass a Context Variable from one screen to another by incorporating it into the "Navigate" function, i.e.:
Navigate(screenSuccess, ScreenTransition.Fade, {ctxtReqID: frmNewRequest.LastSubmit.ID})
Hi @bcanfield83
Context variables are scoped to a screen, which means that you can't build a formula that refers to a context variable on another screen. If you've used another programming tool, you can think of a context variable as similar to a local variable. Use the Set function to work with global variables that are available throughout your app.
Set(ctxtReqID, frmNewRequest.LastSubmit.ID)
If you have any questions or feedback, please let me know. Have a great day! 😊
-----------------------
PowerYsa Power Platform Enthusiast [LinkedIn] | [Youtube]
I love to share my knowledge and learn from others. If you find my posts helpful, please give them a thumbs up 👍 or mark them as a solution ✔️. You can also check out my [@PowerYSA] for some cool solutions and insights. Feel free to connect with me on any of the platforms above. Cheers! 🍻
WarrenBelz
146,596
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,928
Most Valuable Professional