Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

This question already has an answer here:

I am trying to assign my own GUID to a list I am creating but am having difficulties. Currently I am creating the list with the code:

site.Lists.Add(CONFIGURATION_LIST_NAME, CONFIGURATION_LIST_DESCRIPTION, SPListTemplateType.GenericList);

Which returns a GUID, but I would like to supply my own. Is there anyway to do this in SharePoint 2010?

share|improve this question

marked as duplicate by Muhammad Raja, Karthik Jaganathan, Benny Skogberg MCSA Nov 18 at 9:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
why do you need to assigne GUID yourself? –  Alexander Mar 22 '12 at 18:34
    
So I can have a static class that contains all my GUIDs, and CTID's. I guess I can just grab the returning GUID from the site.Lists.Add() method and use it then. –  Meyer Denney Mar 22 '12 at 18:39
2  
I would definitely recommend letting SharePoint assign the GUID and just pulling it after the fact. Its a much safer and better guaranteed to avoid issues in the future. –  Zork Mar 22 '12 at 18:44

1 Answer 1

up vote 2 down vote accepted

No, the guid for the list is used directly by SharePoint to store items in the SQL-tables common to all site collections/sites in a Content database.
If they allowed you to assign that yourselves it would cause problems of people storing information in multiple lists with the same Guid which SharePoint would the read for all of the lists. Which might also allow you to read/write information which you shouldn't have access to.

Even Microsoft got all the checks in place and prevented you from creating new lists with the same guid (also when you moved site collections to new content databases). It would mean that activating your feature in one site collection would disallow it in any other in that database.

So all in all I think it's good you can't control it

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.