Expand nested lookup fields

Copper Contributor

Hi everyone, I'm wondering something about retrieving lookup fields value in spfx projects.

 

/**
 * Gets Sharepoint <Employee Required Files> list items
 * @returns Employee Required Files list items
 */
export async function getRequiredDocuments() {
    const documents: any[] = await sp.web.lists.getByTitle(REQUIRED_DOCUMENT_LIST_NAME).items.select("Title", "Type/Title", "Keyword", "Profile/Title").expand("Type", "Profile").get().then((items: any[]) => {
        console.log(items)
        return items;
    });
    return documents;
}

 

In this code snippet (which works perfectly), I'm retrieving the values from the Type field (lookup field), and specifically the value in the Title field from this looked up list.

 

Now, what if the Title itself or any other field in this looked up list, is ALSO a lookup field to read from.  How would we then access it given that we are in a case of nested lookup fields?

 

I haven't find any example on the web at this point that solves this problem.

 

Thanks a lot for the reading and helping!

 

Maxime

0 Replies