SubPointSolutions / spmeta2

SharePoint artifact provision for .NET platform. Supports SharePoint Online, SharePoint 2019, 2016 and 2013 via CSOM/SSOM.
http://subpointsolutions.com/spmeta2
134 stars 56 forks source link

Field type changing #1090

Open vlad-ivanov-d opened 7 years ago

vlad-ivanov-d commented 7 years ago

Hello,

Do you support an availability of changing a field type? If yes, I've found a little bug: When I try to change the field type from "Text" to "Note" if fails with an exception:

field or property "NumberOfLines" doesn't exist

It looks like SPMeta2 tries to set a property "NumberOfLines" on "Text" type field and fails because of such property doesn't exist. This property is only actual for "Note" field type. So SPMeta2 should change field type from "Text" to "Note", and then set properties.

I use SharePoint 2016 On-Premises, CSOM, and SPMeta2.CSOM.Foundation v1.2.130

Field definition:

public static NoteFieldDefinition Coordinates()
{
    return new NoteFieldDefinition
    {       
        Id = new Guid("7d021794-f805-4a5f-ad10-95892b68a522"),
        Title = "Coordinates",
        InternalName = "Coordinates",
        Group = ".Test",
        AddFieldOptions = BuiltInAddFieldOptions.AddToAllContentTypes,
    EnforceUniqueValues = false,
    NumberOfLines= 6
    };
}
avishnyakov commented 7 years ago

No, unfortunately changing field types isn't supported right now.

There are a few tickets related to this:

In a nutshell, it's a complex operation from both implementation and testing. Plus it might turn out in a data loss or corruption.

On a radar, might happen in a few month from now depending on the current workload.

vlad-ivanov-d commented 7 years ago

Oh, I see. It will be good. Thank you for so fast reply!

avishnyakov commented 7 years ago

Not a worry. We might do that mid-November.