Solved

Sharepoint Knowledgebase: How to automatically generate and assign a document ID?

Posted on 2010-11-10
9
1,055 Views
Last Modified: 2012-05-10
Experts:

I'm setting up a knowledge base within Sharepoint Services using the Knowledge Base plugin provided by Microsoft.  I've got the website up and running and I know how to add customized columns when documents are being created.

What I want to tackle now is a unique ID for the document.  When a user creates a document, I want a field called Document ID to auto generate a document ID for the document.  This ID is unique to the document and will never be used again.

Any ideas on how I can do that?
0
Comment
Question by:piattnd
  • 4
  • 4
9 Comments
 
LVL 43

Expert Comment

by:zephyr_hex (Megan)
ID: 34103519
if it's just one library, you can use the built in ID field.  it's hidden by default.
http://geekswithblogs.net/hinshelm/archive/2008/01/11/unique-id-in-sharepoint-list.aspx

if you need something that is global (covers more than one library), or this built in ID field doesn't suit your requirements, then you'll need to build a customization.  in my opinion, the easiest way to do this is using SQL.  you'd create a table that calculates and stores your ID.  maybe even using an Identity column.  SQL will enforce the uniqueness requirement, and handle the calculation of the next ID.  you'd then need to associate this to your library... and there are various ways in which to do that.   but try the built-in ID column first.
0
 
LVL 12

Author Comment

by:piattnd
ID: 34104591
So is there a way to force this field to be readable (read only) upon creation of the document?  I want the users to create a new document and name the folders to contain the images specifically to the ID of the document.
0
 
LVL 12

Author Comment

by:piattnd
ID: 34105818
I meant during the creation of the document, sorry for the mis-wording there.
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 43

Expert Comment

by:zephyr_hex (Megan)
ID: 34105848
that built-in ID is read-only.  the user can not change it.  sharepoint assigns it, and it is unique.  there are situations in which this ID just doesn't work.  one situation is if you need it to be unique across multiple libraries.  that built-in ID is only unique within that library.

another example of some trouble with that ID is when you need the ID before the item is created.  the ID is assigned as part of the item creation, and so it's not available beforehand.  

so, if the document is added first, then you can use that ID to name the folder.  but you can't name the folder before the doc is created.  there are ways around this particular issue, or... you can use a different method for assigning the ID.  SQL is one way, and i've seen other solutions, too.
0
 
LVL 43

Expert Comment

by:zephyr_hex (Megan)
ID: 34105889
one more thing...
i am pretty sure that the ID does not get re-cycled if an item is deleted.  you can test it to check.  add the ID to the display of your library.  create an item, note the ID, and then delete the item.  then add another item.  i am pretty sure sharepoint will not re-use that deleted item's ID.

for some people, this is a problem because they want more of an "incrementer" than a unique ID... something that doesn't have gaps.  but as i recall, that ID field is indeed unique to the docs in the library.
0
 
LVL 12

Author Comment

by:piattnd
ID: 34106919
Yeah, the thing I just thought about too is what happens if I had to restore my site from a disaster.  Would that ID be reset?  I would think not, but I'm not too sure.

Do you have any links for the custom solution using an SQL table to calculate the next available ID?
0
 
LVL 15

Assisted Solution

by:sharepointguru14
sharepointguru14 earned 50 total points
ID: 34108367
are you using sharepoint 2010 or an older version? If you are using 2010 then this is a new feature that is offered out of the box. It will assign a 100% unique ID to all documents where enabled. All you have to do is
enable the Document ID Feature from Site Collection Features. When this is done you will see a new option under ‘Site Settings -> Site Collection Administration‘ called Document ID Settings. When you click on this you will see a bunch of options. 1 being assign ID's this will give a unique id and you can then even move the documents to other sites and this link to the document will still be valid. It also allows you to prefix the number and a bunch of other things.

If you are using an older version this has been a pain point. Using the ID column will work as stated above as long as you are only looking for the ID to be unique within that library.
0
 
LVL 43

Accepted Solution

by:
zephyr_hex (Megan) earned 450 total points
ID: 34113255
if you restore, the ID remains the same as before.

here is an example of how to do it using SQL IDENTITY:
http://stefvanhooijdonk.com/2010/06/21/document-id-provider-the-last-one/
0
 
LVL 12

Author Comment

by:piattnd
ID: 34114105
We are not using sharepoint 2010, but I did see where it has a unique ID feature.  I don't know if we'll upgrade that way or not.

For now, I've gone ahead with manually assigning unique IDs to the documents.  Thank you both for your time and suggestions.

I'll look into the SQL IDENTITY link.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A question that is asked often, is how to generate sequential numbers in InfoPath Forms. The best way to achieve this is to use a SQL database, along with a stored procedure and a web service to connect Forms Services to the DB. The first thing t…
We had a requirement to extract data from a SharePoint 2010 Customer List into a CSV file and then place the CSV file into a directory on the network so that the file could be consumed by an AS400 system. I will share in Part 1 how to Extract the Da…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question