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 / Add a new row in share...
Power Apps
Unanswered

Add a new row in sharepoint list for a user on entry to the powerapp.

(0) ShareShare
ReportReport
Posted on by 2
I am new to PowerApps and trying to finish a half-built app. I am trying to have my app initialize my user in my sharepoint list if they do not exist in it already. My app is properly pulling from the list if the user is already in it, but I am struggling to make the user get added to it if they are not in it. The ClearCollect definitely works right here because elsewhere I can access this data if the user is in it, but I am more confused on patching here. This seems to be the syntax I have gathered from other forum posts, but something seems to not be right as this does nothing right now. I currently have this in my OnStart section of the app before a bunch of other variables are declared. Thanks!
ClearCollect(
    UserData,
    Filter(
        'MyData',
        'Sharepoint User'.Email = User().Email
    )
);

// If the user does NOT exist, add them to the data source
If(
    (IsBlank(UserData)),
    Patch(
        'MyData',
        Defaults('MyData'),
        {
            'Sharepoint User': {Claims:"i:0#.f|membership|" & User().Email, Department:"", DisplayName: User().FullName , Email: User().Email , JobTitle:"" , Picture: "" }
        }
    )
);
Categories:
  • ANB Profile Picture
    7,252 Super User 2026 Season 1 on at

    Hi @mikekrau Try this code:

     

     

     

    If(
     CountRows(UserData) = 0,
     Patch(
     'MyData',
     Defaults('MyData'),
     {
     'Sharepoint User': {
     '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
     Claims: "i:0#.f|membership|" & User().Email,
     Department: "",
     DisplayName: User().FullName ,
     Email: User().Email,
     JobTitle: "",
     Picture: ""
     }
     }
     )
    );

     

     

    You are missing with '@odata.type' field and IsBlank cannot be used on collection. Instead use CountRows

     

    -----------------------------------------------------------------------------------------------------------------------------

    I hope this helps.

    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.👍

    Thanks,
    ANB


     

  • Mitanshu Profile Picture
    1,658 Moderator on at

    UserData is a collection and not a Record so IsBlank will not work, you should try:

    IsEmpty(UserData)

     

    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 this post or my previous reply was useful in other ways, please consider giving it Thumbs Up.

  • mikekrau Profile Picture
    2 on at

    @ANB that definitely is helping me make progress, now I seem to have a different error. It says when I am doing this... "Network error when using Patch function: 'Title' field required". I do not even have a Title column in my sharepoint list though even when I go to view in list settings, so this does not seem to make sense to me.

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard