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?
Asked
Active
Viewed 924 times
1 Answers
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:
![](../../users/profiles/5726128.webp)
Jerry
- 3,052
- 1
- 8
- 10