Can I control the data type of a custom field?
I'd like to add a long or integer custom field to an object.
On the edit custom field screen I select Number as the Data Type as it seems like the only applicable custom field type. Currency and Percent wouldn't work.
On the Edit Custom Field screen I can alter the Length and Decimal Places custom field attributes. Setting the decimal places to 0 makes sense.
Length is a bit more tricky as I can't express the data type limits by the number of digits alone. E.g. integer spans -2,147,483,648 to 2,147,483,647, so at best I could had 9 digits before it would risk overflowing. For long 18 digits would take all but the most significant bit (so I could never actually store the maximum long value in a custom number field).
When working with the custom number fields in apex the data type is always decimal. So I need to convert to and from the required data type.
Via the partner API the soapType is xsddouble with the scale matching the decimal places and the precision the digit length.