SugarCRM SupportHelp ArticlesStudio and Module BuilderSugar LogicCalculated Field - Copying Dropdown Value to a Text Field

Calculated Field - Copying Dropdown Value to a Text Field


This article will walk through how to use the getDropdownValue() function in a Sugar Logic formula to copy a value from a dropdown field into a custom text field.

For an overview on Sugar Logic and Calculated Fields, please refer to the article Introduction to Calculated Fields.

Use Case

In this example, we will copy the value of "Customer" in the Account Type dropdown field into a new text field. With our first formula, we will copy the value to a new field on the same module so that our account type can be mirrored on the second tab of the Accounts detailview even though the original field is only present on the first tab. We will also create a second formula that copies the field value to a different, related module. This will copy the account type to a field on the related Contacts module so that each contact record will display the account type of its related Account.


You will need a dropdown field that is populated for your test record. You will also need to create a new field of type TextField and mark it as calculated before entering the following formula.


The formula below will copy the value in the Account Type field to the new text field on the Accounts module.


If you would like the value of the dropdown field copied into a new text field in a different module, you can enter the formula below.


Formula Breakdown

The getDropdownValueDropdown() function in the first formula returns the display value of the option currently selected for Account Type. This function first requires the name of the dropdown which can be found by looking in Studio > {Module Name} > Fields > {Dropdown Field} > Drop Down List. The second input is the dropdown itself. For our example, the formula will write "Customer" into the new text field since the Account Type field has a display value of "Customer" selected.

For the second formula, we still need to provide the getDropdownValue() formula with the dropdown field. Since that field does not exist on our new text field's module but rather on a related module, we will use the related() function to reach across to the related module and access the desired field. The related() function needs both the module name (or relationship name in the case of a custom relationship) as well as the desired field's name. You can use Studio's Formula Builder's Related Field button to produce the right module or relationship name. For our example, all Contacts related to this Account will show "Customer" in their new text field.


Once your custom text field is created with the calculated value formula and added to the module's detailview, it will display the value of the dropdown field.


Last modified: 2018-05-11 04:50:47