0

I used SPFx (1.10) Yeoman generator with SharePoint Online version.

I created a column with "Person and Group" field and tried to get an item detail from a list by using PnP JS version 2.0.7:

import { sp } from '@pnp/sp/presets/all';

const data: any = await sp.web.lists
      .getByTitle(`ItemList`)
      .items
      .getById(id)
      .select(
        'Person_x0020_or_x0020_Group/Title',
        'Person_x0020_or_x0020_Group/Id',
        'Person_x0020_or_x0020_Group/Created',
        'Person_x0020_or_x0020_Group/EMail'
      )
      .expand(
        'Person_x0020_or_x0020_Group',
      )
      .get();

console.log('ACTION RESULT', data)

In my expectation the result will be:

[
   {
      Created: "2016-07-17T06:56:04Z",
      Id: 21,
      Title: "Person1 Members",
      EMail: "person1@<tenant-url>.com",
      odata.id: "4f18225b-1687-4fc7-b7a9-2f660ec2815e",
      odata.type: "SP.Data.UserInfoItem",
   },
   ...
]

But the console will return status code 500 and print an error:

"Cannot get value for projected field Person_x0020_or_x0020_Group_x005f_EMail."

Anyone know how to solve this?

0

If the user does not have an email address (the administrator has not assigned EXchagne license to this user), the requst will go wrong.

Below is my test:

const item= sp.web.lists.getByTitle("listname").items.getById(8).select("Customer/Title","Customer/ID","Customer/EMail").expand("Customer").get();
console.log("item: ", item);

User has email: enter image description here

User has no email: enter image description here

More reference:

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.