In a site collection I've activated Document ID, using https://support.office.com/en-us/article/Enable-and-configure-unique-Document-IDs-ea7fee86-bd6f-4cc8-9365-8086e794c984

Is there a code that has input the document ID and returns respective document's properties (like URL)?

1 Answer 1


Document Id value is stored inside a column whose internal name is _dlc_DocId. The document's url is stored inside an internal sharepoint column whose name is EncodedAbsUrl.

To fetch the URL of the document which has a particular document ID(assume its SOMEUNIQUEID-09-04), you need to make a CAML query on the _dlc_DocId column and then fetch the related data.

Please try and modify the below sample code (this is for one particular document library):

function getFileByDocumentId(documentID){

    var ctx = new SP.ClientContext.get_current();

    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml('<View><Query><Where><Eq>' + 
        '<FieldRef Name=\'_dlc_DocId\'/><Value Type=\'Text\'>SOMEUNIQUEID-09-04</Value>' + 

    var items = ctx.get_web().get_lists().getByTitle('Documents').getItems(camlQuery);
    ctx.load(items, "Include(Id, Title, Author, EncodedAbsUrl)");
    ctx.executeQueryAsync(function () {
        var listEnumerator = items.getEnumerator();
        while(listEnumerator.moveNext()) {
            var currentDocument = listEnumerator.get_current();
            var fileUrl = currentDocument.get_item('EncodedAbsUrl');
        console.log("something went wrong");


As you mentioned in the comments that there could be multiple document libraries, your best bet would be to use SharePoint search.

After document ID feature is activated and the site collection is crawled, SharePoint creates a crawled property ows_dlc_DocId which is mapped to a managed property DocId.

enter image description here

If its not there, then you can create your own managed property and map it to this crawled property.

Once done, you need to wait for the crawl to be completed.

After, you can go to your search center, or create a page with search results webpart and then search the documents as below:

enter image description here


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.