SPFx save selected user to a people column?

Iron Contributor


I am trying to fetch the name of a user with the PeoplePicker component and then save it in a list that contains a Person column. 

There is something in the method that create the new item in the list that is wrong and can't create the item. 

Just for testing I created a new column of type single text and the method was available to create the new item, so there is something that I am missing in order to save the name in the Person column. 

This is what I have until now:

The PeoplePicker from pnp/spfx-controls:

titleText="Sales Manager"
groupName={""} // Leave this blank in case you want to filter from all users

The _getManager method that update the state:

private async _getManager(items: any[]) {
await this.setState({ people: items[0].text.toString() });

And this is the _create method that should save the item in the list:

private _createItem(): void {
Title: this.state.Title,
people: this.state.people

This same _create code works if I save the people in the state to a single line column. But with a Person column I get this message in the console: 

A 'PrimitiveValue' node with non-null value was found when trying to read the value of a navigation property; however, a 'StartArray' node, a 'StartObject' node, or a 'PrimitiveValue' node with null value was expected.

And I can't find the waty to make it works.


Best regards


0 Replies