1

I need to fetch item from SharePoint list using CAML query, if specific column is modified. How to achieve this?

3
  • try to write in more details, possibly with example – Gaurravs Jan 18 '16 at 11:59
  • If 'specific column' is modified how? Please provide more details as this question is far too vague. – psdpainter Jan 18 '16 at 19:06
  • I need to fetch list item from list only when specific column like "Name" is modified.If any other column is modified,no need to fetch other item.Is it possible to query the list using CAML query,to check whther the item is modified.If modified,whther the specific column is modified,if so..then i need to fetch the data. – sherin Jan 19 '16 at 4:32
0

CAML query will not be able to handle this for you as far as I know. Updates to columns are logged in the audit system of SharePoint and the history tables. You can't scan a list looking for a change to a specific column using CAML query. It won't have that level of refinement.

Your only option is to use code to view the version history of the item and determine if the value has changed within each version of the history. This can only be done if you are tracking history in your list.

However, since you are SharePoint Online managed code is also not going to work for you and CSOM doesn't have any hooks into History either that I am aware of. You will have to utilize SPServices to get the history data for you from SharePoint online (information: http://spservices.codeplex.com/wikipage?title=Versions). Using the following code will get you a list of each version of the item. You can then loop through them to find out if your field has been modified.

$().SPServices({
  operation: "GetVersionCollection",
  async: false,
  strlistID: "<LIST NAME>",
  strlistItemID: <LIST ITEM ID>,
  strFieldName: "<Column You are Checking",
  completefunc: function (xData, Status) {
    $(xData.responseText).find("Version").each(function(i) {
      console.log("Name: " + $(this).attr("Information") + " Modified:     "     +     $(this).attr("Modified"));
    });  
  }
});
1
  • is possible to get multiple columns (strFieldName) data – ranjith Aug 21 '17 at 12:52

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.