Converting a Multiselect Field to a Dropdown Field

    Overview

    Both multiselect and dropdown fields allow users to select from a list of options when editing the field. The field types differ, however, in that multiselect fields allow multiple options to be set while dropdowns only allow for one. There may be occasions where you wish to convert an existing multiselect field to a dropdown field to better suit your business’ needs, however, it is not possible to switch field types on existing fields in the Sugar application. This article covers how to mass update existing multiselect field’s values and then run a database query to change the field to a dropdown.

    Use Case

    As an example, we will convert a custom multiselect field in the Accounts module to be a single-select dropdown field. 

    Prerequisites

    This change requires a query to be run directly on your instance’s database, so you will need access to the server hosting your database as well as administrator access in Sugar. If you need assistance making these changes and already have a relationship with a Sugar partner, you can work with them to make this customization. If not, please refer to the Partner Page to find a reselling partner to help with your development needs. 

    Note: Customers hosted on Sugar’s cloud service should file a case with the Sugar Support team to make this database change. 

    Steps to Complete

    Mass Updating Multiselect Fields

    Before converting the multiselect field, you should take steps to ensure that you do not lose any data that may already be stored in the multiselect field. Records that contain multiple values for the field will lose data after making the database change to a single-value field. Therefore, you must mass update the records that contain multiple values to only contain the single value that you want to preserve.

    You can mass update records via the module’s list view or via import. For more information on mass updating records via the module’s list view, please refer to the User Interface documentation. For more information on mass updating records via import, please refer to the Updating Records Via Import article.

    Converting the Field

    Once you have updated the necessary multiselect field per the instructions above, you are now ready to convert your multiselect field to a dropdown field: 

    1. Navigate to Admin > Studio > {Module Name} > Fields.
      • Note: Replace {Module Name} with the name of the module that contains the multiselect field you wish to change to a dropdown field.
    2. From the field list, click on the multiselect field you wish to change and take note of the value next to “Field Name”, which is the field’s database name. In the following example, the field’s database name is test_field_c. We will use this value in the next step.
      test-field
    3. Next, log into your database and run the following SQL query, replacing test_field_c with the database field name noted in Step 2.
      UPDATE fields_meta_data SET type="enum" WHERE type="multienum" AND name="test_field_c";
    4. After executing the update query, log into Sugar as an administrator and navigate to Admin > Repair and perform a Quick Repair and Rebuild. This will rebuild the cached files to fully implement the changes. 

    Application

    Now that the multiselect field has been converted successfully, users will only be able to select a single value from the dropdown list going forward.

    in Studio and Module Builder

    Reach out to us for help