Let the platform do the work

Fields

Overview

How fields interact with the various aspects of Sugar.

SugarField Widgets

The SugarField widgets, located in ./include/SugarFields/Fields/ , define the data formatting and search query structure for the various field types. They also define the rendering of fields for modules running in backward compatibility mode. When creating or overriding field widgets, developers should place their customization in ./custom/include/SugarFields/Fields/. For information on how Sidecar renders fields, please refer to the fields section in our user interface documentation. Creating Custom Fields

Implementation

All fields for a module are defined within vardefs. Within this definition, the type attribute will determine all of the logic applied to the field. For example, the Contacts module has a 'Do Not Call' field. In the vardefs, this field is defined as follows:

  'do_not_call' => array (
    'name' => 'do_not_call', // the name of the field
    'vname' => 'LBL_DO_NOT_CALL', // the label for the field name
    'type' => 'bool', // the fields type
    'default' => '0', // the fields default value
    'audited'=>true, // whether the field is audited
    'duplicate_on_record_copy' => 'always', // whether to duplicate the fields value when being copied
    'comment' => 'An indicator of whether contact can be called' // admin context of the field
),

The bool type field is rendered in the UI from the ./clients/base/fields/bool/bool.js field controller which renders the appropriate handlebars template as defined by the users current view for sidecar enabled modules. When the user saves data, the controller formats the data for the API and passes it to an endpoint. Once the data is received by the server, The SugarField definition calls any additional logic in the apiSave function to format the data for saving to the database. The same concept is applied in the apiFormatField function when retrieving data from the database to be passed back to the user interface through the API. For modules running in backward compatibility mode, the bool field is rendered using the Smarty .tpl) templates located in ./include/SugarFields/Fields/Bool/.

While the vardefs define the default type for a field, this value can be overridden in the metadata of the view rendering the field. The example being that in ./custom/modules/Contacts/clients/base/views/record/record.php, you can modify the do_not_call field array to point to a custom field type you have created. For more information on creating custom field types, please refer to Creating Custom Fields documentation.

Last Interaction and Last Opportunity Dates

Last Interaction is a read-only system field on Leads, Contacts, and Opportunities as well as Accounts. Only Held Calls and Meetings qualify. The implementation uses the interaction’s End Date, date_end. Accounts use the static Account relationship; Opportunities use Related To; Leads and Contacts can qualify through Guests or Related To. Removing a qualifying relationship, deleting an interaction, or changing its Held status triggers recalculation.

Accounts also gain Last Opportunity Date, calculated from the latest creation date of related Opportunities. It measures opportunity creation rather than communication. New fields are added automatically to default, unmodified layouts; add them manually to customized layouts where required.

Grouped Address Fields

Studio adds the Address (Grouped) field type. It presents Street, City, State, Postal Code, and Country as a single address group in layout configuration, with the component fields retained for storage and field-level operations. Use the generated metadata to identify each component when building an API mapping.

Existing custom address fields are not automatically converted. To adopt a grouped address, create the group, map and migrate existing data, update layouts and integrations, and retire the old fields only after validating the replacement. Review installations of the earlier GroupAddressFields package for overlap with the native implementation.

Integration Sync ID

Integration Sync ID, sync_key, can be placed in additional Studio layout types including list, record dashlet, preview, popup, search, subpanel, and mobile layouts. It remains read-only in the user interface.

The field is also available in Sugar Logic and Action Button formulas, and its values are available for Global Search subject to access permissions. A visibility or read-only formula can test whether the record has an external integration identity. Evaluate this against the value loaded from the server; the read-only UI field is not a user input control.

not(equal($sync_key, ""))

This example is true when Integration Sync ID is populated.

Topics