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
Configured Commerce - Introduction to Long-Term Support (LTS) Releases

First off, for those who have not had a chance to meet me yet, my name is John McCarroll, and I am the Technical Product Manager for the Optimizely...

John McCarroll | Sep 29, 2023

Auto-translate with OpenAI in Optimizely CMS

You can now auto-translate content using your favorite online AI service, inside the old trustworthy Episerver.Labs.LanguageManager!

Tomas Hensrud Gulla | Sep 29, 2023 | Syndicated blog

Vulnerability in CMS 12 shell module configuration

Introduction A potential security vulnerability has been identified in Optimizely CMS 12, triggered by a certain shell module configuration. To be...

Magnus Rahl | Sep 28, 2023

AI-Assistant: The 'Change Tone' Shortcut

The AI-Assistant for Optimizely is constantly evolving, adjusting, and transforming to meet your digital needs, providing a cutting-edge advantage...

Luc Gosso (MVP) | Sep 27, 2023 | Syndicated blog

How to fix scheduled job 'Remove Abandoned BLOBs' if it keeps failing

Optimizely inlcudes a job named 'Remove Abandoned BLOBs'. This post will help you fix it if it's no longer working.

Henning Sjørbotten | Sep 26, 2023 | Syndicated blog

Optimizely Web Experimentation Metrics

Within the domain of Optimizely Web Experimentation Metrics, the emphasis is on objective key performance indicators (KPIs) selected to assess an...

Matthew Dunn | Sep 23, 2023 | Syndicated blog