ARJR

Does anybody know how to set the Unique Id for a document A code sample if possible.

Thanks.



Re: SharePoint - Development and Programming Unique ID

Gary A. Bushey MVP

The ID field that you can see for a document cannot be set. It is the internal GUID used by SPS.




Re: SharePoint - Development and Programming Unique ID

ARJR

Thanks for the info.

What I really want to do is programatically submit a document using a unique value for the document name. For example work order #1. I want to save the incremented value in a document list and then retrieve the next value when the submit occurs. How would you do this. thanks.





Re: SharePoint - Development and Programming Unique ID

Curtis Ruppe (MicroStaff IT)

You would probably want to have a parsing engine that would be very similar to your autoname assigner, just in reverse. C# code:

Code Snippet

string strOldName = "work order #1";

string strNewName = "";

int currentCount = "";

currentCount = Convert.ToInt32(strOldName.Substring("work order #".Length))+1;

strNewName = String.Format("work order #{0}", currentCount);

The trick then would be to get the largest number. That would most likely invole using the SPList.GetItems method with a query to get the newest item by the Created DateTime property.

http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.splist.aspx has a good example of using an SPQuery. The only thing to be aware of is that the SharePoint datetime field does not easily translate to a .NET DateTime type.