1

I have a content type which has a field called "Owner" which currently is of type User.

The code has been deployed to production and has been so for ~1 year so they have a lot of data in the application.

The client has requested that the "Owner" field be changed to a UserMulti type field along with a list of other (mostly server code) changes.

I have changed the definition from

<Field ID="{110F87F3-5FE2-4067-AAB5-86DF93EEB319}" 
       Group="Custom Columns" 
       Name="ComponentOwner" 
       DisplayName="Owner" 
       Description="The person who owns the component" 
       Type="User" 
       Required="TRUE" />

to

<Field ID="{110F87F3-5FE2-4067-AAB5-86DF93EEB319}" 
       Group="Custom Columns" 
       Name="ComponentOwner" 
       DisplayName="Owner" 
       Description="The persons who owns the component" 
       Type="UserMulti" 
       UserSelectionMode="1"
       Mult="TRUE"
       Required="TRUE" />

My fear is when I send the updated solution to be deployed an error saying a field with that GUID already exists will be thrown.

How can I ensure that the solution gets deployed smoothly and at the same time update the Type of this field in the content type and all lists using it?

3
  • 1
    I would probabyl handle this in a feature updating event receiver to change the field properties. Jun 1, 2015 at 12:06
  • 1
    True, I will also prefer doing it programmatically on updating event receiver Jun 1, 2015 at 12:10
  • @EricAlexander That seems like a viable solution to the issue. It's a one-off thing, so I guess a powershell script to do it might be sufficient as well.
    – user2536
    Jun 1, 2015 at 12:21

1 Answer 1

1

Try something like this

SPList lista = sitio.RootWeb.Lists[listaP];
SPFieldUser columna = (SPFieldUser)lista.Fields[columnaP];
if (!columna.AllowMultipleValues)
{
  columna.AllowMultipleValues = true;
  columna.Update();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.