문제

While updating item in SPFx I am getting below error:

Uncaught (in promise) TypeError: Cannot read property 'getByTitle' of undefined

enter image description here

도움이 되었습니까?

해결책

Try using below imports before updating list items:

import { sp } from "@pnp/sp";
import "@pnp/sp/webs";
import "@pnp/sp/lists";
import "@pnp/sp/items";

OR

import { sp } from "@pnp/sp/presets/all";

Then you can update the list item like:

let list = sp.web.lists.getByTitle("Control Documents");

const i = await list.items.getById(itemId).update({
  BMSTwoApprovalStatus: "Retired",
});

Reference: @pnp/sp/items - Update

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top