Using: SharePoint 2010, JavaScript, jQuery 1.10.2, SPServices

In SharePoint 2010 I have a custom (JavaScript-based) page where users may type in text and link to items in SharePoint lists. A recent requirement has made it necessary to also include the Modified date, something I'd like to do automatically, since I can't expect users to think to update this page every time they update the linked document.

As an example, if a user has the text "Information Paper" linked to the item stored at https://mysite.com/sites/123/1234/MyPaper.docx, the script needs to be able to extract the URL from the anchor tag (already working), use the path and file name to locate the exact item, gather the Modified date on the file, and append it to the existing link text. That way, the user's "Information Paper" becomes "Information Paper (11 April 2014)".

It looks like SPServices' Query operation may be able to handle this, but I don't know how/if I can use a path to return the specific item's information.

Any ideas on how to do this?

1 Answer 1


I think you would use SPServices GetListItems operation and specify the CAMLQuery option with a CAML query designed to only get the item(s) with your URL.


    operation: "GetListItems",
    async: false,
    listName: "YOUR LIST NAME",
    CAMLQuery: "<Query><Where><Eq><FieldRef Name='FileRef' /><Value Type='Text'>1234/MyPaper.docx</Value></Eq></Where></Query>",
    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() {
        var modifiedDateTime = $(this).attr("ows_Modified");

The FileRef field is stored as "Library/Folder/filename.extention" so make sure you strip off the root URL to the site from the absolute URL you are starting with.

  • Thanks, for your response, Jared! This approach sounds good, but the listName variable could be different from link to link. In my example above, the path would be "/sites/123/" and the list name would be "1234", but the URL could just as easily contain numerous folders or a number of subsite levels. URLs potentially differ from link to link. I'll test your approach and see if SPServices is smart enough to determine the list name from a full path. Apr 11, 2014 at 16:17
  • Very good. I understand that adds some complexity to the task. Unfortunately I can't offer too much more since all of the jQuery and SPServives approaches rely on the GetListItems web method which is always going to require you to specify the list/library in question. The only thing I can think of would be to recursively call starting with the known top level site, going down each rout in the URL until you find the document in question. Would make the process relly "chatty" but would work in principle. Apr 11, 2014 at 16:58
  • Yeah, that's what I figured, and is likely the direction I'll go. I appreciate you taking the time to offer your insight. Apr 11, 2014 at 17:26
  • Good luck! Let us know how you end up solving it. Apr 11, 2014 at 23:09
  • Still poking at this. So far I've been able to separate the path and file name but SPServices chokes for some reason. I pass in the listName and webURL since files are stored in subsites, but once I get inside completefunc, I'm not getting access to $(this).attr("ows_Modified"). I'll try a question on the SPServices site to make sure the syntax is correct. Apr 25, 2014 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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