0

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.

1

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.

4
  • Yeah I already used this Function, but the Required values do not match what is specified in the list settings (only the title is required). And a field that is created in the list settings is not even showing up in the response. Aug 29 '19 at 7:10
  • Is it not showing the custom fields you created in list? Aug 29 '19 at 7:20
  • Also, you can get the specific fields you want from list by using their internal names. For this, check Filtering Fields - Application specific fields section in reference link code. Aug 29 '19 at 7:22
  • Ohh it turns out that I have been executing my querys on a different list than I thought. (thats why the the fields I'm creating aren't showing up and nothing is working as expected) Aug 29 '19 at 7:29

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.