bswee
bswee

Reputation: 81

Adding new column to existing content type

I added a column into an existing content type. The content type provisions a list instance with deployment conflict resolution set to none.

Post deployment, the column is not showing when I add a new item. However the column is showing in the content type at Library settings.

If I set deployment conflict resolution to automatic, the column is added in the new item but I lose all my data.

What do I need to do to update content type with new column and keep existing data on the list?

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Parent ContentType: LMS Document (LeaveManagementSystem\LMS Document) (0x010100174F5B4B857F41F5893B76351F3001CA) -->
<ContentType ID="0x010100174F5B4B857F41F5893B76351F3001CA02" Name="LMS Project Document" Group="LMS Content Types" Description="LMS Project Documents Content Type" Inherits="TRUE" Overwrite="TRUE" Version="0">
<FieldRefs>
  <FieldRef ID="{EB703A89-8495-40E8-9F42-180E57EA9F1A}" DisplayName="Name" Required="FALSE" Name="LMS_Name" />
  <FieldRef ID="{0214FB1B-051A-4861-91DA-C94324FDCD6F}" DisplayName="Start Date" Required="FALSE" Name="LMS_StartDate" Format="DateOnly" />
  <FieldRef ID="{26780D0B-4F9A-4BD5-AD56-74D625F14946}" DisplayName="End Date" Required="FALSE" Name="LMS_EndDate" Format="DateOnly" />
  <FieldRef ID="{CDD9F593-7C33-41D6-A16F-1CCD99BA3642}" DisplayName="MM Leave Type" Name="MMLeaveType" />
  <FieldRef ID="{AD3E2F37-FA57-49B1-B5DA-5B9B12F3FAAE}" DisplayName="MM Leave Type_0" Required="FALSE" Hidden="TRUE" Name="MMLeaveTypeTaxHTField0" />
  <FieldRef ID="{f3b0adf9-c1a2-4b02-920d-943fba4b3611}" DisplayName="Taxonomy Catch All Column" Required="FALSE" Hidden="TRUE" Name="TaxCatchAll" Sealed="TRUE" Sortable="FALSE" />
  <FieldRef ID="{8f6b6dd8-9357-4019-8172-966fcd502ed2}" DisplayName="Taxonomy Catch All Column1" Required="FALSE" Hidden="TRUE" Name="TaxCatchAllLabel" ReadOnly="TRUE" Sealed="TRUE" Sortable="FALSE" />
  <FieldRef ID="{8ECEC8EA-560B-40BA-A768-D438AD97DAEF}" DisplayName="Leave Comment" Required="FALSE" Name="LMS_LeaveComment" />
  <FieldRef ID="{CAC62009-5A85-4E12-BF80-661EDB9CEF55}" DisplayName="Balance" Required="FALSE" Name="LMS_Balance" />
</FieldRefs>    
<DocumentTemplate TargetName="/Test_DL/Doc1.docx" />
</ContentType>
</Elements>

Upvotes: 1

Views: 1656

Answers (1)

Thibault Gandon
Thibault Gandon

Reputation: 366

Base on our comments, I would suggest you to push the change on an existing list by doing PowerShell script. An another way to do this is to use the Event Receiver of your feature.

In order to push the change, you have to :

  • Get your existing list(s)
  • Add pragmatically your newest column in the list
  • Update your changes

This article'll give you more information about Feature Event Receiver : https://msdn.microsoft.com/en-us/library/ee231604.aspx

This article'll give you the code to add an existing field in a list. https://social.msdn.microsoft.com/Forums/office/en-US/eb1f0ce2-4015-4c77-8e95-dd3c1398daa7/add-a-column-to-a-list-from-existing-site-columns-programmatically?forum=sharepointdevelopmentlegacy

Hope this helps

Upvotes: 1

Related Questions