Set current user as requestor

Hi I thought there was a way to set the current user as the default for a people picker field however I am not seeing documentation or a thread on it.
I have a requestor field that is a people picker that I want to auto fill to the current user.
Any help would be appreciated.

Dear Jennifer,

Please use this code:

fd.spRendered(function(){ 
   fd.field("People").ready().then(function(field) {
      fd.field("People").value = _spPageContextInfo.userLoginName;	
   });  	
})

Notice that you should replace “People” with the internal name of your people picker field.

1 Like

Alex, I am same question. Where put above code?

Hello, @Jack!

Please paste the above code in the JavaScript Editor.

image

hi, i have tried it but the point is that it is returning another user name.

Hello @MehmetMuhanna,

Welcome to Plumsail Community!

What SharePoint version are you using? Could you please share the code you are currently using, that returns the incorrect username.

Hi @mnikitina
i am using sharepoint online.
the strange thing is userLoginName return wrong value, but userDisplayName return correct value.

@MehmetMuhanna,

I see that you've resolved the issue in another topic:

1 Like

yes thanks a lot for your support