web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch: Update sharepoi...
Power Apps
Unanswered

Patch: Update sharepoint list

(0) ShareShare
ReportReport
Posted on by 179

I have an app that records, via Patch OnStart, various info about the user when they first log into the app (see code).

 

 

 

Patch(
 'Mentee Interest Tracking',
 Defaults('Mentee Interest Tracking'),
 {
 PotentialMenteeEmail: User().Email,
 Mentee: {
 Claims: "i:0#.f|membership|" & User().Email,
 Department: "",
 DisplayName: "",
 Email: "",
 JobTitle: "",
 Picture: ""
 },
 Department: Office365Users.MyProfileV2().department,
 Location: Office365Users.MyProfileV2().officeLocation
 }
);

 

 

 

What I want to do is update the record created, in the 'Mentee Tracking List' SP list, when the app was opened (add new info into column not initially populated) if the user selects an entry in a gallery within the same session in the app. The gallery is based around an individual and I would like it to populate a person column in the list.

  • The field in the gallery that identifies the person needed is: ThisItem.'Mentor Name'.Email 
  • The name of the column in the list that needs to be populated is: MentorofInterest

ChrisUndery_0-1681159577002.png

 

I know Patch can do this via the 'OnSelect' elemnet of the Gallery item but cannot work out how

Any help appreciated. 

Categories:
I have the same question (0)
  • BCBuizer Profile Picture
    22,535 Super User 2026 Season 1 on at

    Hi @ChrisUndery ,

     

    What you can do is to save the created item in the App.Onstart property in a variable to use later on in the app when the user selects an item in the gallery:

     

    Set(
    	varCurrentSession,
    	Patch(
    		'Mentee Interest Tracking',
    		Defaults('Mentee Interest Tracking'),
    		{
    			PotentialMenteeEmail: User().Email,
    			Mentee: {
    				Claims: "i:0#.f|membership|" & User().Email,
    				Department: "",
    				DisplayName: "",
    				Email: "",
    				JobTitle: "",
    				Picture: ""
    			},
    			Department: Office365Users.MyProfileV2().department,
    			Location: Office365Users.MyProfileV2().officeLocation
    		}
    	)
    );

     

    In the OnSelect property of the gallery you can then include a new Patch function which will update the item that is saved in the variable:

     

    Patch(
     'Mentee Interest Tracking',
     varCurrentSession,
     {
     MentorofInterest: ThisItem.'Mentor Name'
     }
    );

    The above will work if 'Mentor Name' and MentorofInterest are both People type columns.

  • ChrisUndery Profile Picture
    179 on at

    Hi @BCBuizer.

     

    Both 'Mentor Name' and 'MentorofInterest' are person columns but they are not in the same list. The 'MentorofInterest' is in the 'Mentee Interest Tracking' list whereas the 'Mentor Name' is in a list called 'Find A Mentor'. Both lists are linked to the app.

     

    Its also worth noting that the user might look at more than one mentor per session. the 'Mentor of Interest' column has been set to accept multiple records.

     

    The Patch on the 'OnSelect' returns the following error

    ChrisUndery_1-1681160967037.png

     

    ChrisUndery_0-1681160924702.png

     

  • ChrisUndery Profile Picture
    179 on at

    The actual list column name of the 'Mentor Name' column in the 'Find A Mentor' list is just Mentor

    ChrisUndery_2-1681161448346.png

     

  • BCBuizer Profile Picture
    22,535 Super User 2026 Season 1 on at

    Hi @ChrisUndery ,

     

    The first point, about the column being in different data sources is not an issue. The second, about 'Mentor of Interes' being a multiselect column, is. This means we can't just patch a record to it, but we need to patch a table and append new records as the user selects more options.

     

    In theory this should look something like the below:

    Patch(
     'Mentee Interest Tracking',
     varCurrentSession,
     {
    		MentorofInterest: UnGroup(
    			Table(
    				{
    					_temp: LookUp(
    						'Mentee Interest Tracking',
    						ID = varCurrentSession.ID
    					).MentorofInterest
    				},
    				{
    					_temp: ThisItem.'Mentor Name'
    				}
    			),
    		"_temp"
    		)
    	}
    );

     

  • ChrisUndery Profile Picture
    179 on at

    @BCBuizer That comes up with errors on a few bits. 

    Would it be neater/easier to change the Mentor of Interest' person column back to single select and then patch a new record each time the user clicks on the gallery item. This would still meet my needs.

     

    If so, what would the patch on the 'onselect' need to look like (and assume would need to remove the variable as no longer being used)? I assume it would be the same as the onstart patch but with extra to get the Mentor Name in

  • BCBuizer Profile Picture
    22,535 Super User 2026 Season 1 on at

    Hi @ChrisUndery ,

     

    The cleanest method would be to create a new list in which a new item is created every time the user selects an item in the gallery. This list would save the selected mentor and a reference to the current session as saved in the 'Mentee interest Tracking' list. 

     

    For this to work you still need the variable in order to populate the relation with the 'Mentee interest Tracking' list, so the App.Onstart formula stays the same, but the Gallery.OnSelect changes to:

     

    Patch(
     'Selected Mentors',
     Defaults('Selected Mentors'),
     {
     SessionID: varCurrentSession.ID,
     MentorofInterest: ThisItem.'Mentor Name'
     }
    );

     

    In the above I have picked some of the identifiers which you still may want to change:

    - 'Selected Mentors': the name of the to be created list

    - SessionID: A Text column that saves the ID of the session, creating a relation with the 'Mentee Interest Tracking' list

    - MentorofInterest: A Person column that saves the name of the selected mentor in the gallery.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Kalathiya Profile Picture

Kalathiya 321 Super User 2026 Season 1

#2
WarrenBelz Profile Picture

WarrenBelz 289 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 200 Super User 2026 Season 1

Last 30 days Overall leaderboard