3

I'm using the following code to get a document via its documentid in a ASP MVC application:

...
// Get Document ID
ctx.Load(uploadFile, f => f.ListItemAllFields);
ctx.ExecuteQuery();
documentID = uploadFile.ListItemAllFields.Id;
...

This seems to work fine, but not in combination with the Sharepoint Document ID Service. I have the following prefix: Sales00(docID) for all documents, but the CSOM only returns the docID.

http://sharepoint/subsite01/_layouts/15/DocIdRedir.aspx?ID=(document_id)

If I include a link in my MVC application like above it shows the id as in '81' and not as 'Sales0081'. How to retrieve the correct value?

3

The Site Collection Feature Document ID Services, when activated generates a Unique ID for a Document. The format of this ID is something like PNR6U3ASXZE2-1206519163-68.

In your question you have specified a URL in which you are passing a query string value document_id. I am not sure what value you get in it, and how you get it?

I am sure about 2 things

  1. You should not pass the usual IDs like 81 in URL http://sharepoint/subsite01/_layouts/15/DocIdRedir.aspx?ID=(document_id)
  2. You must pass the actual Document ID which is generated by Doc ID services, which is looks like PNR6U3ASXZE2-1206519163-68. So your URL becomes http://sharepoint/subsite01/_layouts/15/DocIdRedir.aspx?ID=PNR6U3ASXZE2-1206519163-68

You get the Doc ID from the List Item Object something like below.

...
// Get Document ID
ctx.Load(uploadFile, f => f.ListItemAllFields);
ctx.ExecuteQuery();
item = uploadFile.ListItemAllFields;
documentID = item["_dlc_DocId"]
...

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.