Domanda

I am trying to fetch items using lookup but seems like it I cannot expand the child people picker column like there is a restriction in which I can't use person field by expanding the child list. Here's my below code:

$.ajax({
      url: .../_api/Web/Lists/GetByTitle('APP_NAME')/items$select=*, BookingID/ID,BookingID/Author&$expand=BookingID`,
      type: "GET",
      dataType: "json",
      headers: {
        accept: "application/json;odata=verbose",
      },
      success: (resultData) => {
        var listdata = {
          accounting: [],
        };
        console.log(resultData.d.results);
        $.each(resultData.d.results, (index, value) => {
            console.log(value.HasPPEKit)
            listdata.accounting.push({
              Author: value.BookingID.Author,
              ID: value.BookingID.ID
            });        
        });

When I look in console it is giving an error but if I remove the BookingID/Author from filter and Author value and try to fetch only ID value using $select=*, BookingID/ID&$expand=BookingID the ID value is fetching.

Is there a mistake in the API I am doing or is there any other to fetch items from 2 lists?

[and also there are some items which will not match other list. It's like I am using inner join in the list, don't focus on this line much, though].

È stato utile?

Soluzione

This is a known behavior of SharePoint.

Extending Person or Group field using lookup columns is not supported in SharePoint. So, you will not be able fetch or add any filter on Person or Group field from lookup list.

To get the data from 2nd list, you need to use nested REST call. You can filter the list items based on the item ID you will get from BookingID column.

Supported Column Types:

  • Single line of text
  • Number
  • Date and Time

Unsupported Column Types:

  • Multiple lines of text
  • Currency
  • Person or Group
  • Calculated
  • Hyperlink or Picture
  • Custom Columns
  • Yes/No
  • Choice
  • Lookup

Microsoft official documentation: Create list relationships by using unique and lookup columns

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top