Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a SharePoint List Item By Unique Id

Is it possible to get SP List Item by unique Id (without writing a Caml request) if I know a related List Id.

var item = list.GetItemById("CFA9E204-6509-424B-A246-0DE5295C42B2");

When I tried to get item using this code, I received an error: "Input string was not in a correct format."

What's wrong with the GetItemById() method?

Why does it has an overloaded method GetItemById() with a string argument if it understands only integer Id?

EDIT:

I use SharePoint Client Object Model where List entity has no a method GetItemByUniqueId(), but it has the GetItemById() method, which receives string or integer Id.

MSDN Documentation

like image 335
Warlock Avatar asked Dec 19 '12 11:12

Warlock


People also ask

Can SharePoint List generate unique ID?

SharePoint lists have an ID column (hidden by default) which contains a unique number for each entry. It is possible to establish a calculated column in the SharePoint list using this value, however it will break if the list is updated by a Power Automate flow.

How do I display a list ID in SharePoint?

After opening the list you want to modify, click Add column > Show/hide columns if you want to show the ID column(which you may have already done).

What is the unique ID column for?

In a database or spreadsheet, unique identifiers may be designated as a specific column or field to help make sorting and filtering through information easier. This also helps trace information back to a specific user or entity within the system.


1 Answers

Try this:

SPListItem item = list.GetItemByUniqueId(new Guid("CFA9E204-6509-424B-A246-0DE5295C42B2"));

like image 98
Manish Avatar answered Nov 14 '22 10:11

Manish