Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Context Variable error ("Name isn't valid")

(0) ShareShare
ReportReport
Posted on by 56

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.

Categories:
  • bcanfield83 Profile Picture
    56 on at
    Re: Context Variable error ("Name isn't valid")

    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})
  • Verified answer
    SpongYe Profile Picture
    5,580 Super User 2025 Season 1 on at
    Re: Context Variable error ("Name isn't valid")

    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! 🍻

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,596 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,928 Most Valuable Professional

Leaderboard