question

JohnDoe-3825 avatar image
0 Votes"
JohnDoe-3825 asked AvramidouAlexia-6699 published

Use current user as default value in a Person or Group field in SharePoint list

Hi,

I have added a Person or Group field in a SharePoint Online List (also exposed through Team/Microsoft Lists) and I want the current user is the default value. How can I achieve this?

Thanks,
John

office-sharepoint-onlineoffice-sharepoint-server-developmentoffice-sharepoint-server-customization
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@JohnDoe-3825, Do you have any update on this iusse?
If an answer helps you, please remember to accept it as answer via the "Accept Answer" button. :-)

0 Votes 0 ·

@JohnDoe-3825,
Would you tell me whether your issue has been resolved or have any update ?
I am looking forward to your reply.

0 Votes 0 ·
sharatha avatar image
1 Vote"
sharatha answered sharatha edited

If your SharePoint Online Site is using classic experience then you could use below JavaScript for your requirement:

Reference: https://www.sharepointdiary.com/2020/02/sharepoint-online-set-person-group-field-default-value-to-current-user.html

If your SharePoint Online site is using Modern Experience then you could do it using PowerApps, below article will help to do via PowerApps.

https://www.c-sharpcorner.com/article/set-current-user-as-default-value-of-person-group-field-in-powerapps/

Thanks & Regards,

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AllenXu-MSFT avatar image
3 Votes"
AllenXu-MSFT answered AvramidouAlexia-6699 published

Hi @JohnDoe-3825,

Which version of experience are you applying to your SharePoint Online list, modern experience or classic experience?

If you are using modern experience, please refer to the following steps:
1) Go to your list->Power Apps->Customize forms:
32624-1015-1.png

2) Click FormScreen1 on the left Tree view->Advanced on the right->OnVisible->fill the text box with following code:

32632-1015-2.png

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

3) Click the people or group field DataCard(which is named Name_DataCard1 in my example) on the left Tree view:
32600-1015-3.png

Go to Advanced on the right and click on unlock to change properties->fill the variable to “CurrentUser” in the Default column as shown below:
32654-1015-4.png

4) Save the form and publish it to SharePoint. Then you can see the people or group field has been populated with the current user when you “New” item in your list.

If you are using classic experience, please refer to this article to use JS code to meet your needs:
SharePoint Online: Set Current User as Default Value in Person or Group Field

Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.

I hope this information has been useful, please let me know if you still need assistance.


If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



1015-1.png (11.5 KiB)
1015-2.png (59.6 KiB)
1015-3.png (12.9 KiB)
1015-4.png (9.0 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Wow! It works! That was extremely helpful! Thank you very much!

0 Votes 0 ·
MartinCoupal-7090 avatar image
0 Votes"
MartinCoupal-7090 answered MartinCoupal-7090 edited

Maybe using Power Automate and "On new list Item" copy created by into your people field?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.