Question

I want to fetch the List column configuation to check if a field is required or not.

But I am not able to figure out which function to use by looking at the documentation.

Was it helpful?

Solution

Build your endpoint like given REST endpoint below:

siteUrl/_api/web/lists/getbytitle('ListName')/fields?$select=Title,Required

Something like:

import { sp } from "@pnp/sp";
let web = sp.web;
// get the fields in a list
web.lists.getByTitle("MyList").fields.get().then(f => {
    console.log("Field: " + f.Title);
    console.log("Required: " + f.Required);
});

Reference:

PnP JS - Fields.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top