'How to retrieve numerical precision and scale of a field through SugarCRM Rest API

I am currently working on a project to pull data from SugarCRM. In that context I am trying to fetch the available modules and their fields through the /metadata endpoint.

Unfortunately the data from the /metadata endpoint only contains precision information for decimal fields, no info on the scale (or is SugarCRM (or me?) using precision and scale in exactly the opposite intended way?).

Field metadata of other data types like float only contains that information for fields i created myself but not for "pre-made" fields. Currency field metadata does not contain any information about precision or scale.

How can i reliably fetch that information for all fields through the REST API?



Solution 1:[1]

It's indeed the opposite way.

  • len => precision (total number of digits)
  • precision => scale (number of digits after the point)

Also field types have defaults for these that are used if nothing is specified in metadata.

I'm not sure what they are internally, however these are some values that Sugar Studio populates by default:

  • varchar: (255)
  • integer: (11)
  • decimal: (18,8)
  • float: (18,8)

enum defaults to varchar (100) internally, as far as I remember.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jay