cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
smcb123
Helper I
Helper I

Using User() to populate person or group sharepoint list

Hi,

 

I'm trying to automatically populate a sharepoint list person or group field by using the user function, however I can't get this to work.

 

I have a 'creator' field which I want to be automatically set to the current user. I have a create form in which this field won't be available, so I have the visibility set to false. Within the default of the data card, I try to enter User().FullName, however it doesn't like this and gives a squiggly line.

 

It will accept simply User(). If I set visibility to true, I can see that nothing gets populated and when I save the record I can see in sharepoint that nothing has been saved.

 

Does anyone have any ideas?

 

Thanks,

 

Stephen

1 ACCEPTED SOLUTION

Accepted Solutions
rubin_boer
Super User
Super User

hi @smcb123 , i'm curious why are you not just using the "created by" column in SharePoint, it will give you the same information.

 

you can create a variablelike this

Set(
    _CurrentUser,
    {
        '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
        Claims: "i:0#.f|membership|" & Lower(User().Email),
        Department: "",
        Email: Lower(User().Email) ,
        JobTitle: ".",
        Picture: "."
    }
);

 set the defaults items to _CurrentUser and it will save the record - just can't see why though.

 

Hope it helps

R

View solution in original post

3 REPLIES 3
rubin_boer
Super User
Super User

hi @smcb123 , i'm curious why are you not just using the "created by" column in SharePoint, it will give you the same information.

 

you can create a variablelike this

Set(
    _CurrentUser,
    {
        '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
        Claims: "i:0#.f|membership|" & Lower(User().Email),
        Department: "",
        Email: Lower(User().Email) ,
        JobTitle: ".",
        Picture: "."
    }
);

 set the defaults items to _CurrentUser and it will save the record - just can't see why though.

 

Hope it helps

R

ScottShearer
Super User
Super User

@smcb123 

In addition to the information provided by @rubin_boer you might find this video from @aprildunnam helpful as well.  The demonstration on defaulting a person or group column the the current user starts at about 6 minutes in.

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

That's terrific, it worked a treat.

 

Thanks,

 

Stephen

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (2,469)