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

Try our conversational search powered by Generative AI!

Mattias Bomelin
May 19, 2016
  2643
(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

Comments

Please login to comment.
Latest blogs
Azure AI Language – Extractive Summarisation in Optimizely CMS

In this article, I demonstrate how extractive summarisation, provided by the Azure AI Language platform, can be leveraged to produce a set of summa...

Anil Patel | Apr 26, 2024 | Syndicated blog

Optimizely Unit Testing Using CmsContentScaffolding Package

Introduction Unit tests shouldn't be created just for business logic, but also for the content and rules defined for content creation (available...

MilosR | Apr 26, 2024

Solving the mystery of high memory usage

Sometimes, my work is easy, the problem could be resolved with one look (when I’m lucky enough to look at where it needs to be looked, just like th...

Quan Mai | Apr 22, 2024 | Syndicated blog

Search & Navigation reporting improvements

From version 16.1.0 there are some updates on the statistics pages: Add pagination to search phrase list Allows choosing a custom date range to get...

Phong | Apr 22, 2024

Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog