Wednesday, October 20, 2010

DVM - Length Restriction

Things can be real stinging when something works perfectly on your local and crashes on server. Recently i dated an error of database nature, which i always dread. "Error retrieving next record from the database (SBL-DBC-00104)" was constantly coming on server when we did query on our applet. It was working perfectly fine on my local machine. Server logs were not of much help as it constituted same error.
Things are not always what we see.After some hunting i discovered that issue was because of "Text Length Override" user property which was recently added. We wanted to restrict user with certain character limit in description field but there were existing records in that table where count of characters was greater than the limit which we gave in the user property for Description. So eventually the option of using this user property was ruled out as this Table was common across mulitple BusComps. Once again DVM came to the rescue. We created rule set with expression including Length function. Below expression was used for evaluation and DVM was triggered using Runtime events.

Length Check: IIf([Description] IS NOT NULL,Len([Description])<=1000,'Y')

The lifeline here is the Len function which returns the length of the given field.DVM support multiple functions which could be of immense use in real time scenarios. We will discuss more of DVM in future posts.

2 comments:

Anonymous said...

Hi,

I have one query on DVM. As per my knowledge, DVM only triggers once the data is stored in the database (triggers on WriteRecord). So, how we are restricting the user not to enter text greater than 1000 characters. DVM will only throw the alert message but still it allows to save the record with more than 1000 characters.

Please correct me if my understanding is wrong.

Siebelish said...

Hi Anonymous,
Thanks for your comment.We can invoke runtime event on PreWriteRecord event which calls this DVM for length restriction. Basically we can use fields which are exposed on UI or Force Active in validation rules. So prior commit it will count length of string and immediately stop the execution.

I hope it helps.
Regards,
-Rahulp