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

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

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