문제

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: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield_members.aspx

도움이 되었습니까?

해결책

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)
{
  web.Fields.AddFieldAsXml(MyFieldDefXml);
}

More information: http://msdn.microsoft.com/en-us/library/ff798370.aspx#Y209

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top