Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Extending Maximum Length of System Metafields on Business Foundation Objects

Vote:
 

Hi,

We're currently on version (8.11) of EPiServer Commerce.

Is there a way to update the Maximum Length of System MetaFields on Business Foundation Objects?

We've got quite a few fields on the Address BF Object such as Organization, Fullname, Firstname, Lastname, etc thare are being truncated at 64 characters.

Cheers,

Damien

#133375
Sep 03, 2015 9:19
Vote:
 

Of course you can.

There are two thing you'll need to do:

- Manually adjust the columns (should be in cls_Address table)

- run this code to update the business object definition:

            using (MetaClassManagerEditScope scope = DataContext.Current.MetaModel.BeginEdit(MetaClassManagerEditScope.SystemOwner, AccessLevel.System))
            {
                MetaClassManager manager = DataContext.Current.MetaModel;
                MetaFieldCollection fields = DataContext.Current.MetaModel.MetaClasses[AddressEntity.ClassName].Fields;
                fields["Email"].Attributes[McDataTypeAttribute.StringMaxLength] = <new length>;
                fields["Name"].Attributes[McDataTypeAttribute.StringMaxLength] = <new length>;
//other fields
                scope.SaveChanges();
            }

Just make sure you back up databases and every thing before doing this.

Regards,

/Q

#133394
Sep 03, 2015 12:24
Vote:
 

Quan,

As always, your quick replies are a lifesaver.

Thankyou.

#133415
Sep 03, 2015 23:59
Vote:
 

@Quan: Thanks for the information. Can you please tell me where to execute the above code to update the business object definition.

I am using the following 

Episerver Version

Commerce 10.2.2

Commerce Core 10.2.2

Commerce.UI 10.2.2

Looking forward for your earliest response. 

Thanks in advance.

#175823
Mar 03, 2017 8:35
Vote:
 

@Sushant: that code should be executed once, so your best place should be in an InitializationModule 

#175824
Mar 03, 2017 8:42
Vote:
 

I have the same problem

This doesnt seem to work correctly. I seee that metadata is updated, however the actual sql table are not updated, and remains of original length.
At that time this sinchronisattion is supposed to happen?

Maybe I need to force it somehow manualy?

Edit: I'm using Commerce 9.24.1

Regards,

Giedrius

#178708
Edited, May 18, 2017 11:37
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.