SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to create a site column using via a console app. I would ultimately like to be able to migrate the site column and upgrade the same column via this app. To that end, I would need some control over the column's GUID. Is it possible to set GUID using the object model for a site column. I could not get a clue from the API:

share|improve this question
up vote 4 down vote accepted

Yes, you can specify it. Example:

public static readonly Guid MyFieldId = 
  new Guid("{CC1E421C-29BE-4373-81D0-55D5D64B2E3D}");
public static readonly string MyFieldDefXml =
  "<Field ID=\"{CC1E421C-29BE-4373-81D0-55D5D64B2E3D}\"" +
  " Name=\"MyFieldName\" StaticName=\"MyFieldName\"" +
  " Type=\"Text\" DisplayName=\"My Field Name\"" +
  " Group=\"My Columns\" DisplaceOnUpgrade=\"TRUE\" />";

if (web.AvailableFields.Contains(MyFieldId) == false)

More information:

share|improve this answer
Main point here is that you can only do it via XML - so either declaratively in a Feature, or as show here, using the AddFieldAsXml method. – James Love Jul 5 '11 at 20:30
That's right, James – Ashish Patel Jul 5 '11 at 20:34
Ashish, Thank you. I will try this out. But should the Field "ID" take the value of "MyFieldId" in the code above? – Sam Patrick Jul 5 '11 at 20:46
It takes only a valid GUID – Ashish Patel Jul 5 '11 at 20:49
@Ashish I meant to say: should CC1E421C-29BE-4373-81D0-55D5D64B2E3D be replace by 891B57CF-B826-4B0C-9EDF-8948C824D96F in the above code? I see that ID of MyFieldDefXml is not really being checked. Or may be I am missing something? – Sam Patrick Jul 5 '11 at 20:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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