Let’s say your users need to enter an 11-digit number in a field. The number will always be purely numerical (not alphabetical or alphanumeric), but it exceeds the 10-digit limit allowed for fields with the Number field type. What do you do?
You can use a field validation on the text field and use the expression:
Len([<IndexedShortText0>]) = 11 AND (FindOneOf ([<IndexedShortText0>], "!
@#$%^&*_{[]:;<>,.?/=qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM") = 0)
So if one non-numeric character is found, the expression will evaluate to false, and the field validation error message will be displayed to the user.
As an example, we’ll set up a field validation on an indexed field for products.
- Click Admin> Application Customization> Product> Product Field Setup. In this example, we’ll edit Indexed Short Text 1.
- Next to Field Validation, click the fx icon.
- Copy the expression listed above and paste it into the Expression field.
In case you noticed, in our example, [<IndexedShortText0>] is actually the correct field value for Indexed Short Text 1. If you were setting up your own field validation, you’d want to replace the field reference in the expression with the correct one for the field. To do this, you’d use the field drop-down list to insert the correct field value.
- Click Check Syntax and fix any errors. If you get no errors, click Save.
- Back on the Field Edit page, enter a Field Validation Error Message.
- Click Save.
Remember, you have to make the fields available on the page layout for you to test the validation.
For more information on building field valitation expressions, see “Creating Expressions with Expression Builder” in Oracle CRM On Demand’s Online Help.
Comments (4)
Yes, that's a lot easier than you could have done it with a regular expression...
Posted by andrejk | January 26, 2009 11:27 PM
Posted on January 26, 2009 23:27
Hi - I think FindNoneOf(,'0123456789') = 0 would be more efficient. Also, for European users, it means we won't need to enter all the other special characters.
Posted by Terry Chan | January 28, 2009 8:05 AM
Posted on January 28, 2009 08:05
I want to validate Attachment name field in Attachment record type.But Attachment record type does not appear in Application Customization link.
How to proceed forward?
Posted by Wahida | February 25, 2009 1:38 AM
Posted on February 25, 2009 01:38
Wahida, you looked at the right place, but this is a limitation in the application--attachment fields are not customizable and cannot be validated against. It wouldn't hurt to log an SR for an enhancement, though--click Training and Support at the top right of the application, and then click Service Requests. Thanks.
Posted by Pete | March 20, 2009 3:31 PM
Posted on March 20, 2009 15:31