Tuesday, May 20, 2008

Text Length Override

One of my favorite User Properties is "Text Length Override". It is a simple technique for enforcing the length of a text field without ugly popup messages.

If you have a business requirement to restrict user input to a certain number of characters, you have several options. You can find a database column that has the exact number of characters you need. You can create a field validation that will popup an error message if a user enters more characters than required. The user must correct the error condition before being allowed to step off the field. You can do something even more intrusive (with scripting, for example) to alert the user that he or she has made a mistake and/or fix the problem for them.

But a completely non-intrusive, transparent, and elegant way to address the situation is to use the Text Length Override User Property on the field. Text Length Override is a User Property that corrects what almost seems to be a defect in the normal functioning of a BusComp field.

It seems intuitive that a field attribute called "Text Length" would set a limit to the amount of text that could be entered into a field. Probably most people wouldn't bother to look that one up. But the fact is that Text Length does nothing at all unless combined with the Text Length Override User Property. The amount of text that a field will accept is normally determined by the size of the underlying database column.

So how does this work? Suppose the following:
  • You have a BusComp Field called "Short Name".
  • The field is mapped to a column called ALIAS_NAME, which is a varchar(100).
  • The business requires that no more than 30 characters of text can be entered into Short Name.

Here's what you need to do if you want to prevent excess text from being entered, but you don't want a validation message to interrupt the user interaction with the view:
  1. Set the Text Length attribute on the Short Name field to 30
  2. Create a User Property object as a child of the Field.
  3. Set the Name attribute of the User Property to "Text Length Override".
  4. Set the Value of the User Property to "True".*

That's all. The User Property "overrides" the normal functionality of the Text Length attribute (it normally doesn't do anything), and limits the text to the Text Length specified.


* Siebel 8 Bookshelf says that you can set the value of the User Property to anything, even null, and the functionality will be the same. This is a change from previous versions.

3 comments:

Lauren said...

This will only work with setup of Siebel. If putting this into play with existing data, say the field is currently accepting 10 digits of text and you limit it to 6 digits, siebel will fail to pull the existing data that has ten digits submitted and processed on existing records in those tables associated with the change to the field user property on the field of the business component.

Jim Tanner-Uicker said...

Lauren is correct. Text Length Override is an input restriction. Data that was already stored in the database before the user property is implemented will not be affected or validated by this user property.

Similarly, Text Length Override only works on the BusComp layer. EIM Imports, for example, could exceed the text length restriction.

ashunigam said...

This is very useful tool, Jim. Thanks for sharing with us and keep it up.