0

I am new to Sharepoint, and I am stuck on an issue. I am using PnP/PnPjs, and I am trying to get the choice fields from one of the site Columns. I have tried using SPWeb, etc, but there are issues with this in typescript. Is there a way I can import this or another way I can grab this data?

Danny
  • 57
  • 5

1 Answers1

2

Please refer the following code snippet:

Get choice site column definition:

import { sp } from "sp-pnp-js";
      let web = sp.web;
      web.fields.getByTitle("testchoice").get().then(f => {

        console.log(f);
    });

Get choice site column value used in a list:

    web.lists.getByTitle("MyList").items.getById(2).get().then((item: any) => {
      console.log(item.testchoice);
  });

Reference:

@pnp/sp/fields

@pnp/sp/items

Jerry
  • 3,052
  • 1
  • 8
  • 10