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 / Defined variable to st...
Power Apps
Answered

Defined variable to store record ID not working

(0) ShareShare
ReportReport
Posted on by 6

Hi everyone--

I have a PowerApp exhibiting an odd behavior. I set a variable on a button click from a LookUp on the Title entered in a text input.

 

Set(varEditSelectedItemID,LookUp(SharePointList, Title=txtEditFormNumber.Text).ID)

 

 

The variable seems to store the ID correctly, as I have a label set to "varEditSelectedItemID" and it displays the record's ID.

However, both a gallery and form with Item set to LookUp based on the ID of the variable will sometimes fail to work.

 

LookUp(SharePointList, ID=varEditSelectedItemID)

 

 

This usually happens when I first load the app. The variable name is written correctly in the Item for the Form and Gallery. If I edit the above LookUp and delete one letter of the variable and add it back to complete the variable name, it recognizes it again and the form works properly for the remainder of the session. Is the variable name too long? Are there limits on this? Any other reasons why a LookUp for the form won't recognize the variable name at first?

 

(I have reasons I'm storing the ID to a variable and not performing the LookUp based on the text input Title field.)

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    155,290 Most Valuable Professional on at

    Hi @kitkor11 ,

    Search your app (bottom icon on the left) for all instances of varEditSelectedItemID - I suspect it is being set somewhere else.

  • kitkor11 Profile Picture
    6 on at

    @WarrenBelz Thanks for the suggestion. Yes, I set the variable to blank in the screen's OnVisible property and to blank after form submission. Those are the only other places I'm setting the variable. I'd welcome advice if that's not a good idea. However, the app works as I expect in the session after I edit/restore the variable name in the Item property for the form and gallery. I can navigate away from the screen and return, enter a new Title, it fetches the ID and displays all the info in the gallery and form.

  • Verified answer
    WarrenBelz Profile Picture
    155,290 Most Valuable Professional on at

    @kitkor11 ,

    Try setting it to zero rather than blank - this may be a case of confusion with the data type required to store.

  • kitkor11 Profile Picture
    6 on at

    @WarrenBelz Thanks! That was an easy one. I wondered about that. Good to know -- setting variables for record IDs needs to be an actual number and not blank. Zero works just fine and no data is associated with ID=0.

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,045

#2
Valantis Profile Picture

Valantis 675

#3
11manish Profile Picture

11manish 592

Last 30 days Overall leaderboard