2

I see in the Number documentation that Salesforce does some rounding, but I'm observing truncation. In the Number Validation Rules from Salesforce there is a Number Must Be an Integer validation rule that specifies that the following can be used to validate that a field is an integer.

FLOOR( My_Integer__c) <> My_Integer__c

I have a field defined as Number(4,0) and I have that validation rule, but the rule is not firing when a value that is not an integer is entered. Instead it truncates the decimal part.

For example, if I enter in 1.75 it will silently change the value to a 1, without a validation failure.

I would rather have the error message displayed to the user than silently changing the number that was input, but I don't want to change the actual data type from Number(4,0).

For good measure, here's the validation rule: Validation Rule for Integer

I did see https://salesforce.stackexchange.com/a/3455/154 which seems closely related; however, Java's Integer.parseInt (at least in Java 1.6.0_25) throws a NumberFormatException for non Integer values (e.g, "1.75").

I am open to other possibilities, but would rather not have to code something.

The field is in a managed package and I cannot change its definition from Number(4,0).

1 Answer 1

2

If you defined the field with zero decimal places then you do not need that validation rule; you have defined the field to be an integer. I am surprised that Salesforce just silently truncates the input, though, as I would have expected a system error message.

1
  • Thanks. The silent part is what is frustrating. If the field weren't in a managed package I could change its definition and use the validation rule. Nov 13, 2012 at 12:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .