Question

While updating item in SPFx I am getting below error:

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

enter image description here

Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top