0

My question relates to SPFX Field Customizer: how to get full path of document in document library?.

How to I get the Id of the item on which the Field Customizer applies?

I have tried:

event.listItem.getValueByName("Id")
event.listItem.getValueByName("ID")
event.listItem.getValueByName(".Id")
event.listItem.getValueByName(".ID")

When Inspect the object I do not see the ID in the array:

enter image description here

I can however see the Id here:

enter image description here

Worst case, I suppose, is to get value from event.listItem["_values"] like this but it is really dirty

// This doesnt' work
let listItemId = event.listItem["_values"].find(item => item.key === "ID");  
// This works  
event.listItem["_values"].forEach((value: string, key: string) => {
console.log(key, value);
});
2
  • Are you trying event.listItem.getValueByName('ID'); in onRenderCell method or somewhere else? Nov 2, 2021 at 4:52
  • Yes, I am calling it in onRenderCell Nov 2, 2021 at 22:34

1 Answer 1

0

From the screentshot, the event.listItem["_values"] is a Map object, so you could get the ID like this:

let itemId=event.listItem["_values"].get("ID")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.