none
Using PersistID to preserve Document IDs in MOSS2010 - Does it work?

    Domanda

  • The following article may help with what I'm asking:

    http://msdn.microsoft.com/en-us/library/ee559302%28office.14%29.aspx

    I'm doing research on the behavior of the MOSS2010 Document ID functionality, and I am having difficulties moving a SPFile object from one document library to the other.

    If I put a file "Document_A.doc" into document library "DocLib1", and move the SPFile (using the "MoveTo" method on SPFile) to document library "DocLib2", the document ID value is preserved, but it appears that SharePoint is no longer able to find the file using the document ID, either via the SharePoint Document ID link in a list view, or via the Microsoft.Office.DocumentManagement.DocIdLookup API methods.

    Now, if I use "CopyTo" to put the document into "DocLib2", a new Document ID is generated for the copy. This is NOT useful for my purpose, as I want to use a DB-stored DocumentID to reliably find the document again, and if it changes without me knowing about it, my ID will be invalid.

    That said, the link above refers to a "Persist ID" field. From what I can tell, if the "Persist ID" field is set to true before copying the file, the document ID is NOT changed for the copy, but stays the same. Which would be perfect for my purposes...

    ... except it doesn't seem to work. A new Document ID is getting generated for the copy.

    Here is the code where I take an SPFile object, get the Persist ID field, set the property to true and invoke CopyTo. I don't think I've missed anything:

    private void MoveFileTo(string destURL, SPFile fileToMove)
    {
    SPListItem listItem = fileToMove.ListItemAllFields;
    SPFieldCollection fields = listItem.Fields;

    string persistIDFieldName = fields["Persist ID"].InternalName;

    fileToMove.Properties[persistIDFieldName] = true;
    bool persistID = Convert.ToBoolean(fileToMove.Properties[persistIDFieldName]);

    fileToMove.CopyTo(destURL);
    fileToMove.Delete();
    }

    Anyone else doing work with Document ID functionality? What has your experiences been?

     

    Thanks,

    Eli Jones - ERP-Link, a division of Gimmal Group
    mercoledì 9 novembre 2011 00:23

Risposte

  • I've resolved my issue.

    "If I put a file "Document_A.doc" into document library "DocLib1", and move the SPFile (using the "MoveTo" method on SPFile) to document library "DocLib2", the document ID value is preserved, but it appears that SharePoint is no longer able to find the file using the document ID, either via the SharePoint Document ID link in a list view, or via the Microsoft.Office.DocumentManagement.DocIdLookup API methods."

    This was the main challenge I was trying to figure out how to get around. What I hadn't realized is that a full or incremental crawl would restore the ability to find the moved document by document ID.

    Thanks.

    • Contrassegnato come risposta Eli Jones giovedì 5 luglio 2012 20:53
    giovedì 5 luglio 2012 20:53

Tutte le risposte

  • Hi Eli,

    Looking at the design perspective, your latter approach to have two documents with the same DocumentID is not possible as that will cause confusion as to which file should be sent to client when that document is requested through DocumentID.  However, the behavior you described initially regaring SPFile.MoveTo() failing to update the DocumentID store with the location of the new file is interesting.

    Can you try to perform the file move using the SiteManager.aspx page (site actions --> manage content and structure) and see if that gives you the same result as SPFile.MoveTo()?

    Cheers,

    Jeff

    • Proposto come risposta XristosK mercoledì 4 luglio 2012 21:52
    mercoledì 30 novembre 2011 23:32
  • I've resolved my issue.

    "If I put a file "Document_A.doc" into document library "DocLib1", and move the SPFile (using the "MoveTo" method on SPFile) to document library "DocLib2", the document ID value is preserved, but it appears that SharePoint is no longer able to find the file using the document ID, either via the SharePoint Document ID link in a list view, or via the Microsoft.Office.DocumentManagement.DocIdLookup API methods."

    This was the main challenge I was trying to figure out how to get around. What I hadn't realized is that a full or incremental crawl would restore the ability to find the moved document by document ID.

    Thanks.

    • Contrassegnato come risposta Eli Jones giovedì 5 luglio 2012 20:53
    giovedì 5 luglio 2012 20:53