Try our conversational search powered by Generative AI!

Mattias Bomelin
May 19, 2016
(1 votes)

Business Foundation field attributes

Creating a meta field for a BF class of type string will by default result in a db column nvarchar(50). Changing the meta field type to LongText will result in the same.

After consulting the documentation (read decompiler) we learn that an attribute is also needed to actually change the db column type.

The MetaClass.CreateMetaField() function allows to input an AttributeCollection. Adding the attribute LongText with the value “true” to the collection will result in a db column of type ntext.

It's also possible to use the properties from my previous post about validators as attributes when creating meta fields. The meta class validator XML will then be extended with the validation information from the attributes and some of them will also be used when createing the db column.
For example using MaxLength for a string field type will change the default db column nvarchar(50) to nvarchar(x) as well as adding the MaxLength attribute to the validator XML.

Some validator properties have inconsistent naming in the meta field creation process in case you’re wondering why not all validator properties work. For example the validator property 'ValidationExpression' for File field types is represented in the meta field attributes as 'NameRegexPattern', and the validator property 'IsMultiValue' is called 'MultiValue' in the meta field attributes.

Happy coding ;)

Btw, I got questions on the image in my first blog post. It's from an old goat stable in the middle of nowhere in the northern parts of Sweden.

Being an e-commerce geek I think todays image is really fun. It was a delivery to me from a swedish office supplies company who didn't mind reusing boxes from their incoming deliveries (wonder where they've hidden those in the catalog, I looked but couldn't find it). Even for a company within the 'adult' segment, where one of the most common usp's is anonymous deliveries, it would be outrageous making a delivery like that!

Image Bild(33).jpg

May 19, 2016


Please login to comment.
Latest blogs
Change the IP HTTP Header used for geo-lookup in Application Insights


Johan Kronberg | Jun 10, 2024 | Syndicated blog

Copying property values

In this article I’d like to show simple Edit Mode extension for copying property values to other language versions. In one of my previous blogposts...

Grzegorz Wiecheć | Jun 8, 2024 | Syndicated blog

Auto-translate with OpenAI GPT-4o in Optimizely CMS

Improvements for Episerver.Labs.LanguageManager! It's now possible to auto-translate both a page and its children at the same time! Additionally, m...

Tomas Hensrud Gulla | Jun 7, 2024 | Syndicated blog

Upgrade To Optimizely CMS 12 Issue: List item fields have become Required

There are many funny details to be aware of when upgrading from Episerver CMS 11 to Optimizely CMS 12. One of them that might feel a bit confusing ...

Allan Thraen | Jun 7, 2024 | Syndicated blog