3

I have the following situation on our SharePoint 2010 environment. Sometimes it happens, that a document id link of a document in a library does not work anymore. When you click on the link it says this error:

Operation Completed Successfully

No documents with the ID PRODUCTS-xxx-xxx were found in this site collection.

enter image description here

The document is not being changed and even when an incremental or full crawl ran, the document id link is still not working.

This is happening in one specific document library of a site collection. Other document libraries in the site collection does not have this issue.

I already tried the solutions in this post, but these did not help either.

SP2010 - After upload Doc ID is assigned, but using the Doc ID link results in No documents with the ID where found in this site collection

Any ideas why this happens and what I can do in this situation to make the link work again?

--- UPDATE ---

I was able to find out that as soon as I open the document once and save it again, the document id link works again after the next crawl.

--- UPDATE 2 ---

After a few weeks we had the same situation on the same library as well on a different one. Rather by chance I found out that the cause might not be the Document ID link, but maybe a permission problem.

I had the following situation:

I used the Document-ID link for a document with my personal account. It works fine. Later, I was logged in as another user who lacked permissions on the Site Collection. Here I received exactly the above error message. When I gave the permissions to the user and an incremental crawl was completed, the user could also use the Document-ID link and no longer received the error message.

Now I wonder, if there might be some difficulties with the User Profile Synchronization Service, that the users might not be recognized correctly anymore and therefore the error message appears. The rights on the Site Collection or in the libraries do not change. There are also no special permissions at file level, only at library level.

Has anyone here had any experience with how to investigate this further, or maybe they have already had problems with the User Profile Synchronization Service? Of course, the User Profile Synchronization Service is just a guess at the moment...

1

The problem here seems not to be search, but the DocumentID.

Is there anything in the one Library that is modifying the Documents or Ids? You should also check that all EventReceivers are still registered and working. There should be at least

  • ItemAdded
  • ItemUpdated
  • ItemCheckedIn
  • ItemUncheckedOut

registered.

  • There are several libraries in this Site Collection that all have the same structure and the same EventReceiver working on the documents. The ItemCheckedIn and ItemUncheckedOut methods actually are not needed. And I think, this cannot be the problem, because the doc id service is working well on the other libraries. – dns_nx Jul 1 at 7:37
  • Please see also my update in my orignal post. – dns_nx Jul 1 at 8:00
  • Well, this could mean two things: 1. Your search-enging is really, really broken and full-crawls do not capture new/modified data but incremental works.. Or.. 2. The "update" triggered a new document-id-generation which the following incremental-crawl found. I'd investigate the latter first. – Nils Jul 1 at 8:14
  • Seriously: You need to find what's messing the Document-IDs. Could be Workflows, Custom EventReceivers, Apps working directly on the library. Word is always a candidate: If you open the document in Word, then directly "Save As" different name in the same library, strange stuff happens.. – Nils Jul 1 at 8:32
  • The document id is still the same. Even after the updates of the EventReceiver. It is really strange. In the document are mainly PDF documents stored. So this is no issue with Word. – dns_nx Jul 1 at 15:37
0

I was able to fix this issue, but it is just a workaround. What this issue caused I still don't know.

I've updated all documents without changing them. Therefore I wrote a small console program with csom to update all documents and write a log file with faulty documents. Maybe someone helps this, too.

public struct Dokument
{
    private int _ID;
    private string _Permalink;
    private string _DisplayName;

    public int ID { get => _ID; set => _ID = value; }
    public string Permalink { get => _Permalink; set => _Permalink = value; }
    public string DisplayName { get => _DisplayName; set => _DisplayName = value; }

    public new string ToString()
    {
        return ID.ToString() + ";" + DisplayName + ";" + Permalink;
    }
} 

class Program
{
    static void Main(string[] args)
    {
        try
        {
            string sharePointServerBaseUrl = "http://portal.xxx.de/";
            ClientContext clientContext;
            System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("xxx", "xxx");
            List<Dokument> fehlerListe = new List<Dokument>();
            clientContext = new ClientContext(sharePointServerBaseUrl + "sites/products")
            {
                Credentials = credentials
            };
            Microsoft.SharePoint.Client.List list = clientContext.Web.Lists.GetByTitle("Chemical Legislation");

            CamlQuery camlQuery = new CamlQuery();
            camlQuery.ViewXml = "<View><RowLimit>10000</RowLimit></View>";

            ListItemCollection collListItem = list.GetItems(camlQuery);
            clientContext.Load(collListItem,
                    items => items.Include(
                    item => item.Id,
                    item => item.DisplayName,
                    item => item.File,
                    item => item.HasUniqueRoleAssignments));

            clientContext.ExecuteQuery();
            int counter = 0;
            foreach (ListItem listItem in collListItem)
            {
                Microsoft.SharePoint.Client.File file = listItem.File;
                clientContext.Load(file, f => f.ListItemAllFields);
                clientContext.ExecuteQuery();

                ListItem item = file.ListItemAllFields;
                var fieldUrlValue = item.FieldValues["_dlc_DocIdUrl"] as FieldUrlValue;
                string permaLinkUrl = fieldUrlValue.Url;
                if (CheckLink(permaLinkUrl) == "text/html; charset=utf-8")
                {
                    Dokument fehlerDokument = new Dokument
                    {
                        DisplayName = item.FieldValues["FileLeafRef"].ToString(),
                        Permalink = permaLinkUrl,
                        ID = item.Id
                    };
                    fehlerListe.Add(fehlerDokument);
                    item.Update();
                    clientContext.ExecuteQuery();
                }
                Console.WriteLine("Item: " + counter.ToString() + "/" + collListItem.Count.ToString());
                Console.WriteLine("Items with error: " + fehlerListe.Count.ToString());
                counter++;
            }
            string logFileName = "results_" + DateTime.Now.ToString("dd-MM-yyyy__H-m-s") + ".txt";
            foreach (Dokument dok in fehlerListe)
            {
                string docPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                using (StreamWriter outputFile = new StreamWriter(Path.Combine(docPath, logFileName), true))
                {
                    outputFile.WriteLine(dok.ToString());
                }
            }
        }
        catch(Exception)
        {
                throw;
        }
    }

    public static string CheckLink(string fileUrl)
    {
        try
        {
            if (fileUrl.StartsWith("http"))
            {
                System.Net.WebRequest req = System.Net.HttpWebRequest.Create(fileUrl);
                req.Method = "HEAD";
                req.UseDefaultCredentials = true;
                using (System.Net.WebResponse resp = req.GetResponse())
                {
                    return resp.Headers.Get("Content-Type");
                }
            }
            return string.Empty;
        }
        catch (Exception)
        {
            return string.Empty;
        }
    }
}

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.