SugarCRM API Metadata endpoint. Properties - How to define an updatable field?

Hi,

When querying the /rest/v11/metadata?type_filter=modules endpoint we can see the list of fields under the /fields object.

Some fields have the property "readonly", as the name implies this defines if this field can be used on Create/Update endpoints.

Some other fields do not have the read-only property, but have a property "type" set to link, relate, another module name, etc.

On the other hand,  most of them have the source=non-db, but some of these fields are updatable.

Some others can not be used in Create/Update, the server does not throw an error, but again the values are ignored.

As far as I've seen this has to do with 1-1 or 1-* related fields/modules or calculated fields.

The question is: How can I precisely define if a field is read-only or not from the metadata? What are all the combinations of properties to make a field read-only?

Thanks!

Parents Reply
  •   ,

    I gathered few smart engineers here to answer your question so here it is:
    It's not easily determined from metadata alone because there are several ways it can hit a readonly condition:
    1. Field is defined as 'readonly' => true ,
    2. Field is defined as 'calculated' => true as Sid noted, but only if 'enforced' => false is not also set
    3. Field is defined as conditionally readonly based on a SugarLogic formula, for example: 'readonly_formula' => 'not(equal($id,""))',
    4. There are Role restrictions not available through metadata
    5. There may be JS code in a particular view that make the field readonly at runtime
    Perhaps if you share your use case with all of us, we could come up with a suggestion.

    SugarCRM | Principal Developer Advocate

Children
No Data