Change length in a Contact field

Vote:
 

Hi

I need to change the max length for a field in Contact. The field is a string...

I tested this.

using (MetaClassManagerEditScope scope = DataContext.Current.MetaModel.BeginEdit("Contact", AccessLevel.System))
            {
                MetaFieldCollection fields = DataContext.Current.MetaModel.MetaClasses["Contact"].Fields;
                var fieldToChange = fields["MyField"];
                fieldToChange.Attributes["MyField"] = 4000;
                scope.SaveChanges();
            }

But didnt work. Checked the field in DB in table cls_Contact and the length is the same as before.

Do I must to change it manually?

#209537
Nov 17, 2019 10:47
Vote:
 

I think you can use only the registered type and it might not be possible to update the lenght.

Here you can see meta field type meta information

Mediachase.BusinessFoundation.Data.Meta.Management.MetaFieldType

What if you manually update in DB? Is that working?

#209541
Nov 17, 2019 18:33
Juan Munoz - Nov 18, 2019 8:59
Yes, I could change it direct in to DB, but I guessing that is better to do it with code...
Vote:
 

The "correct" attribute name is McDataTypeAttribute.StringMaxLength, however I think that can only be applied when you create a new metafield. Once you created the field you can't just change the length of the column 

#209553
Nov 18, 2019 10:13
Juan Munoz - Nov 18, 2019 10:55
Yes, sorry It was misspelled.
fieldToChange.Attributes[McDataTypeAttribute.StringMaxLength] = 4000
I change direct in DB, it did work... But i will not recommend that, becouse the cls_Contact table has some dependency to other table...
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.