I have webpage that uses a client side people picker and allows the user to address a message to other valid users within our on-prem SharePoint 2013.
I'm trying to write a record of the message to a list and having problems with the Recipients part of the list item. Recipients is a multipick people column.
I've found many tutorials like this one which show that Recipients will get another hidden field called RecipientsId and that I can use a REST call like
data: { "__metadata": { "type": "SP.Data.ListNameListItem" },
"Title": "The title",
"RecipientsId": ["5","7"] };
But there are a couple of reasons the <name>Id
column won't work. First The user Id number is based upon if the user has visited my site (or maybe site collection?) In any event a user who visits my site might send to a recipient who has never been to my site and therefore doesn't have a local user id.
The other problem is that I'm following this on how to use the client people picker and it shows how to get the details about the people in the picker with this code:
var peoplePicker = this.SPClientPeoplePicker.SPClientPeoplePickerDict.peoplePickerDiv_TopSpan;
var users = peoplePicker.GetAllUserInfo();
But the information returned about the users in the people picker doesn't include the Id. I assume this is also because of issue #1 where the user in the people picker may not have an Id on the current site. Here is the information that is returned.
AutoFillDisplayText:"First Last"
AutoFillKey:"i:0#.w|domain\IdNumber"
AutoFillSubDisplayText:"Job Title"
AutoFillTitleText:"[email protected]↵Active Directory↵domain\IdNumber"
Description:"domain\IdNumber
DisplayText:"First Last"
DomainText:"collectionurl"
EntityData:Object
EntityType:"User"
IsResolved:true
Key:"i:0#.w|domain\IdNumber"
LocalSearchTerm:"first last"
MultipleMatches:Array[0]
ProviderDisplayName:"Active Directory"
ProviderName:"AD"
Resolved:true
What I would like to do is user the Key
or AutoFillKey
or Description
to populate the Recipients Column. I have tried those and also tried stripping out the leading i:0#.w
and/or domain with no success.
TL;DR
Is there a way to directly write to a person column (and not the hidden related Id) using the REST api?
If there isn't...
How do I get the UserId for a user based on the info available in a people picker?
How to I get a UserId for someone who has never been to my site?