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

Was it helpful?

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

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top