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 / PowerApps SharePoint I...
Power Apps
Answered

PowerApps SharePoint Integration: Global variable

(0) ShareShare
ReportReport
Posted on by 4

Hello friends,

I have an issue. I have a list on the SharePoint Site that looks:

Smile1_0-1601279329934.png

Then I have tried to customize Edit Form on PowerApps that uses a global variable for the SharePointIntegration.Selected record.

I have added the following code OnEdit event of SharePointIntegration component:

Smile1_4-1601280031707.png

And OnCancel event:

Smile1_5-1601280110221.png

On the screen, I have a form that uses the SharePointIntegration.Selected record as Item

Smile1_6-1601280216809.png

And a label that uses the variable

Smile1_7-1601280281332.png

(All the following photos contain a part of the SharePoint list on the left side and custom PowerApps in Edit mode on the right)

And then when I open the form on the SharePoint first time everything works well

Smile1_1-1601279510919.png

Then I close the form and try to open it for another record and it works for but not for my variable.

Smile1_2-1601279574803.png

If I open third time another record the form works but a variable shows me the second record.

Smile1_3-1601279688569.png

So, do you happen to know how to set a global variable properly?

(I understand that I may use the SharePointIntegration.Selected record for the label as well but my purpose is to use this record for setting other variables)

 

 

Categories:
  • Verified answer
    v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Smile1 ,

     

    Yes, I can also reproduce your issue, and can't find out the reason of this issue for the time being.

    However, here is another workaround, change to use LookUp function to retrieve back the record upon the 'SharePointIntegration.SelectedListItemID', rather than 'SharePointIntegration.Selected'.

    Please try to modify the code as follows.

    Set(
     SelectedWorkflow,
     If(
     IsBlank(SharePointIntegration.Selected) || IsEmpty(SharePointIntegration.Selected),
     First([@'SP list']),
     LookUp('SP list',ID= SharePointIntegration.SelectedListItemID)
     )
    );
    

    Hope this helps.

    Sik

  • Smile1 Profile Picture
    4 on at

    Thanks, it works.

  • ahady Profile Picture
    2 on at

    It works perfectly except for the first-time run (I guess it is related to App initialization. tried the same code-snippet in the App OnStart, but unfortunately didn't make any difference. still brings the 

    First([@'SP list'])

     as a result and not the SharePoint selected item.

    Any suggestions please, am really tired of this bug, been days now, and my form is quite complex enough

     

  • lfernandes Profile Picture
    13 on at

    Curious - did you ever find a solution to fix the first run?

  • samstarzy Profile Picture
    38 on at

    I am having a similar problem. I have tried to set a global variable (Boolean: E.G. varNewForm = true) to capture when the form is new vs. when it is being edited. PowerApps defaults to an "Edit" form mode, regardless of the form being started as "New", so this is my attempt at a workaround.

    When I open a New form, the variable is set to "true" correctly. However, when I then open an item to "Edit", the variable does not get set the first time. Then when I open the item again, the variable does get set to "false". I do not understand why my code will run the second time, but not the first. Very frustrating. 

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 224 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 126

Last 30 days Overall leaderboard