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 / Global variable to sto...
Power Apps
Answered

Global variable to store Sharepoint Item ID won't update on OnStart or OnVisible

(0) ShareShare
ReportReport
Posted on by 21

Hi, I have a Powerapp linked to a Sharepoint list. I want to store the ID of the selected item (where applicable) to a Global Variable, but nothing works

 

I have tried: 

OnStart

=>If(MyForm.Mode=FormMode.New,Set(vClaimID,Blank()),Set(vClaimID,Int(IdValue.Text)))

I figured the landing screen (where the item's ID control is) not having loaded yet at OnStart, I'd have better chances using:

=>If(MyForm.Mode=FormMode.New,Set(vClaimID,Blank()),Set(vClaimID, SharePointIntegration.SelectedListItemID))

=>If(MyForm.Mode=FormMode.New,Set(vClaimID,Blank()),Set(vClaimID, SharePointIntegration.Selected.ID))

Outcome: the global variable is either blank or =1

 

Next, I tried variations of all of the above in the OnVisible property of my app's landing screen. All failed.

I then moved on to: 

=> creating a hidden button within the EditForm. The button's OnSelect property was set as follow: Set(vClaimID,Int(IdValue.Text))

=> ditto with:

Set(vClaimID,SharePointIntegration.SelectedListItemID) or 

Set(vClaimID, SharePointIntegration.Selected.ID) or  

Set(vClaimID,Int(varLabel.Text))

 

I then tried all of the above with a 3 second timer to delay the time the variable gets set and ensure the form had time to load.

 

All the while, the label I've created to display the item's ID (Text = IdValue.Text) displays the row ID correctly...

 

Finally, I tried loading that one piece of information into a collection, both on OnStart and OnVisible

ClearCollect(MyCollection,ShowColumns(Filter(MyDataSource, ID=SharePointIntegration.SelectedItemID),"ID"))

ClearCollect(MyCollection,ShowColumns(Filter(MyDataSource, ID=SharePointIntegration.Selected.ID),"ID"))

Played with a number of variations on "OnVisible", such as using a label to get the ID

ClearCollect(MyCollection,ShowColumns(Filter(MyDataSource, ID=Int(VarLabel.Text)),"ID"))

and other variations on the theme....

The collection remains empty.

 

Yes, I ran OnStart after every change.

 

Also tried with Set(vClaimID, ClaimForm.LastSubmit.ID), however Submit only works if changes have been made, so -even if I set a button to automatically select the button and submit the form at the OnVisible stage - nothing would have changed so no ID would be returned.

 

The only time the variable populates is when navigating away from the screen and navigating back to it, thus forcing OnVisible to run once more.

 

Stumped. I must be missing something really obvious.

There's no way something as basic as loading a row ID into a global variable when the app/screen loads would be  that much work.

 

Also tested using a context variable instead: same thing.

Only works if I navigate away from & then back to that screen.

 

Thanks in advance! 

Categories:
I have the same question (0)
  • Verified answer
    LiOtto Profile Picture
    21 on at

    right, I have a working (but pathetic!) solution:

     

    I created a loading screen, set the Sharepoint OnView property to Navigate(LoadingScreen).

    That loading screen has got a hidden timer that auto-runs (3 seconds) and the  OnTimerEnd property is set to Navigate(ClaimScreen).

     

    When the ClaimScreen loads, both Global & Context variable update as expected.

     

    I do hope someone will suggest a less clunky solution...

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 529 Most Valuable Professional

#2
Haque Profile Picture

Haque 230

#3
Kalathiya Profile Picture

Kalathiya 217 Super User 2026 Season 1

Last 30 days Overall leaderboard