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 / SharePointIntegration ...
Power Apps
Answered

SharePointIntegration : strange behaviour

(0) ShareShare
ReportReport
Posted on by 331

Hello all,

When displaying a sharepoint record in a form ; I'm trying to display the ID of my selected record in a field but I always get the id number of my previous choice ! ?  Here's the situation :

 

On the 'OnView' of my sharepointIntegration element ; i've the following instructions

Set(varFormMode; FormMode.View);;
Set(varFormItem;SharePointIntegration.Selected)

On the item value of my sharepointForm element ; I've the following : 

SharePointIntegration.Selected

In my SharepointForm, I've a field with the followed defined value : 

varFormItem.ID

 

Now, when I selected a record in my sharepoint list, for example the blue record here above. I expected to have the ID 53 in my field VarFormItem

forstera_0-1709740705326.pngforstera_1-1709740778836.png

 

I then select another record ; let's say the one with the ID 54 (Information rentrée) and here's what I get (ID 53 of the previous selected record) : 

forstera_2-1709741215949.png

 

So I'm always 1 record 'late' when displaying the id of the selected record.

do you know why I get this behaviour ? 

Thanks to al all for your help

 

 

 

Categories:
  • WarrenBelz Profile Picture
    156,940 Most Valuable Professional on at

    Hi @forstera ,

    That is because SharePoint does not run App OnStart or Screen OnVisible when selecting another record unless the user refreshes their browser between each selection. Therefore your Variable will not be reset and you will see the last time it was refreshed. The idea of this app was that the only thing that would change between records is SharePointIntegrated.Selected, therefore the app is "kept open" and does not expect anything else to be run.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • forstera Profile Picture
    331 on at

    Dear WarrenBelz,

     

    Thanks for your explanation. So if I understand you correctly , the function SharePointIntegrated.Selected always return the correct value but in my case, the event OnView is not called everytime I click on a record of my sharepoint list ?

     In this case, which event could I use to refresh the value of my variable ? 

    Thanks for your help 🙂

  • WarrenBelz Profile Picture
    156,940 Most Valuable Professional on at

    Hi @forstera ,

    SharePointIntegration.Selected will always return the last record that was selected by the user from SharePoint, which is why the standard form Item is based on this. There is no event you can call automatically if you simply select another record without refreshing the SharePoint list in the browser. The form will open and if the Item is based on a Variable, it will be from the the last time it was set. Your Form Item needs to be based on SharePointIntegration.Selected - and it will update with each new record selected - in your model, from what I can see, you really do not need the Variable.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • forstera Profile Picture
    331 on at

    Thanks for your answer. I asked that because I need a variable for the next step of my form (I didn't described it here). In short, I've another form included in my screen wich is a child of my main form. I need to synchronize it according to the main record. 
    I've 2 different cases I've to manage : viewing a record and adding a record. In both case I need the id of my main form to synchronize my subform. But when adding a new record, I first need to save it, than change ma form mode from adding to view ; that's why I need a varialbe ; to store my id. I already had the following functions but still had this problem I described in my first post. Here are the whole instructions :

    SharePointIntegration
    --------------------------------------------------
    OnCancel:
    	Set(varFormMode, FormMode.View);
    	Set(varFormItem, Blank());
    	ResetForm(SharePointForm1);
    	RequestHide()
    
    OnEdit:
    	Set(varFormMode, FormMode.Edit);
    	Set(varFormItem, SharePointIntegration.Selected);
    	ResetForm(SharePointForm1)
     
    OnNew:
    	Set(varFormMode, FormMode.New);
    	Set(varFormItem, Blank());
    	ResetForm(SharePointForm1)
     
    OnSave:
    	SubmitForm(SharePointForm1)
     
    OnView:
    	Set(varFormMode, FormMode.View);
    	Set(varFormItem, SharePointIntegration.Selected);
    	ResetForm(SharePointForm1)
     
    SharePointForm1
    ----------------------------------------------------
    DefaultMode: 
    varFormMode
     
    Item = varFormItem
    
    OnSuccess: 
    Set(varFormItem, SharePointForm1.LastSubmit);
    Set(varFormMode, FormMode.View);
    ResetForm(Self)



  • WarrenBelz Profile Picture
    156,940 Most Valuable Professional on at

    @forstera ,

    I can see what you are trying to do and it is something you would have no difficulty with in a Canvas App. The unfortunate issue is that relying on Variables to be automatically set in an Integrated App when simply changing records is not a plan you can rely on. These apps were designed to be a simple interface to add/delete/change/view records and replacing either the standard SharePoint form or in some cases an InfoPath Form (I won't explain that one except to say they are legacy pre-power apps).

    There is nothing technically wrong that I can see with what you have done except a lot of it simply does not run when changing records. I do a lot of Integrated Forms and have given up on referencing the current record anything other than based directly on SharePointIntegrated.Selected.

    However, for your child list, in the same session, there is nothing wrong with setting a Variable OnSuccess of  SharePointForm1.LastSubmit.ID, so maybe you head that direction.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • forstera Profile Picture
    331 on at

    @WarrenBelz Thank you for your explanations.

     

    In the meantime, I found a post that seems to work but doesent understand it at 100% :

     

    On the OnSuccess action of your form, add the following:
    
    Set(glbCurrentRecord, Self.LastSubmit)
     
    
    Then change your Item property to:
    
    Coalesce(
     glbCurrentRecord;
     SharePointIntegration.Selected;
     First(List1)
    )

    What do you think ? 

    Thanks for your help 🙂

  • Verified answer
    forstera Profile Picture
    331 on at

    ok, I made a test with the function colaese and it worked fine ! I can now display my records 🙂 thanks to @randyHaye

     
     
  • Verified answer
    WarrenBelz Profile Picture
    156,940 Most Valuable Professional on at

    @forstera ,

    Yes that is exactly what I was referring to (the first part) - set a variable to the last submitted ID if you want to use it in another list. The second part is just a variation (the same result) of what Power Apps initially has standard on a Form Items and is also (as I posted) what you need to use.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

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 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard