SharePoint 2010 ClientObjectModel : Find Item by GUID - sharepoint

I have a list of 6000 listitem GUIDs. I need to check if each item still exist on the Web.
Previously, I was using the SPWeb.GetFile(GUID) method to check the item.
But now I need to convert that process usinig the ClientObjectModel. I cannot find a way to retrieve the item using the GUID.
I even tried from the "List" object. And can't find a way to retrieve the item from its GUID neither.
Please help! :(

Try to use CAML Query.
Ex CAML Query:
<Query><Where><Eq><FieldRef Name='ID'/><Value type='Counter'>"+fileIDtoFind+"</Value></Eq></Where></Query>
For more details see: http://msdn.microsoft.com/en-us/library/ie/ee857094.aspx

Related

How get List of items from Netsuite using java api

How I can get Item list from NetSuite using suite talk java API. I am
able to get single item using internal Id but I need to get All list of items or by pagination (batch). Please advise how can I do this?
Code for get one inventory item:
RecordRef recordRefs=new RecordRef();
recordRefs.setType(RecordType.inventoryItem);
recordRefs.setInternalId("6")
ReadResponseList responseList = client.callGetRecords(recordRefs);
Use a search. You'll probably want an advanced search, since you're retrieving so many results. Here's a great example of an advanced search with pagination: https://stackoverflow.com/a/47538464/10393810
(Note that you will be using an ItemSearchAdvanced, not TransactionSearchAdvanced as in the example)

SharePoint 2010, CAML query to see if a new item has been added to a list (Announcements)

all. I am trying to build a CAML query for a SP2010 list that will check the Announcements to see if anything new has been added (or a CAML query + some functionality). I do not truly understand CAML and SP yet and would be grateful for any help - thank you.
Have a look around an SPQuery object if you want to go down the CAML route.
You will want to get all the items for a given date/time range unless you have a field that flags if an item is new..... the link below should help you build a query
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/fed59f8e-72e2-46e2-9329-460fd65d7536/caml-query-datetime
Once you have a SPQuery object pass it to the SPList GetItems() method
You will then have a collection of items what you do with them then is all up to you :)
Hope this helps

Get List Item by Guid without List in SharePoint

Could anybody help me to get List Item by unique Id in SharePoint without using List? I know the List Item unique Id, but I haven't information about List. Using Client Object Model I can do the following:
using (SP.ClientContext clientContext = new SP.ClientContext(...))
{
**SP.List list = clientContext.Web.Lists.GetById(listId);**
SP.ListItem listItem = list.GetItemById(listItemId);
clientContext.Load(listItem);
clientContext.ExecuteQuery();
...
}
Unfortunately, in this code I use listId, but the problem is that in my task I don't know listId, I have only ListItem Guid. Since I have unique Id, I believe that there must be a way to get this Item without using any additional information.
You've posted a snippet with a Client Object Model, so I suppose it's a preffered object model for the solution. However, if it's acceptable for You, I've found some information on how to achieve this using server side object model, which You may find helpful.
It seems that this can be done using SPWeb.GetFile(Guid itemGuid) if the item exist in the root site.
If you want it to work also for subsites, you can use SPWeb.GetSiteData method to invoke caml retrieving an item as explained in this article: http://www.chakkaradeep.com/post/Retrieving-an-Item-from-the-RootWeb-and-Subwebs-using-its-UniqueId.aspx.
You can also take a look at this thread on SO for some additional information:
SharePoint: Get SPListItem by Unique ID.
If you have any issues using those methods, let me know. I'll also look for alternatives for this to run with Client Object Model and I'll post them if I find some, however, it seems to be more difficult to achieve.

Dynamically building CAML query in SharePoint 2010

I have an requirement of get the items from the list depends on the ItemID.I have list which contains 5000 items in which I retrieve only 1000 items for that I will dynamically build the CAML query using JohnHoliday CAML.NET and the query have 1000 conditions at that time I got Value does not fall within the Expected Range error. The query works fine upto 150 items but it throws error when the ItemID increases.Could you provide a suitable workaround for this issue ?
You're running into the size limit for CAML queries, which AFAIK isn't documented anywhere, but definitly exists.
If you only need to support 2010 then you can use the new <In> operator which probably with get you a bid further
In sharepoint 2010 there is a List view threshold configuration that give the administrator the ability to determine the maximum items you can retreive in a one patch
and to overcome this problem you can use
ContentIterator
check this link for more help
Why not iterate over SPList.Items and take which items you need? So there's no need to build a complex caml query. Or call SPList.GetItemByUniqueId.

SharePoint CAML OrderBy Modified does not work

I have made a query against a list. I want to get the last modified item which meets a certain condition, and my query looks like this:
<Query><OrderBy><FieldRef Name='Modified' Ascending='FALSE' /></OrderBy><Where><Eq><FieldRef Name='kortnummer'/><Value Type='String'>kv11</Value></Eq></Where></Query>
I get the listitems i need, just not in the right order. Changing Ascending to true does nothing, so obviously there is something with the OrderBy clause that is not right..
According to MSDN it should be possible to order by Modified.
Any idea why my OrderBy does not work?
I always put the OrderBy after the Where.
Otherwise you could make sure that you are using the internal name. I usually use SharePoint Manager 2007 to get the internal field names. Codeplex SharePoint manager
I can see that on a list in my SharePoint, the modified column internal name is "Last_x0020_Modified".
If you're doing this in a C# string to get an SPListItemCollection, you don't need "<Query></Query>" tags.

Resources