Display field in CRM Web UI as ComboBox with domain values

Problem: you want to display a field in the CRM Web UI as a ComboBox. The list should contain values from the specified domain.

Solution: what you need to do is to redefine the V-Getter of the field you want to change into a ComboBox. After redefinition, paste the code below and change the name of the domain.

  DATA:
    lt_values TYPE bsp_wd_dropdown_table.
 
  SELECT domvalue_l ddtext
    INTO TABLE lt_values
    FROM dd07t
    WHERE domname = 'YOUR_DOMAIN_NAME'
      AND ddlanguage = sy-langu.
 
* insert an empty value into the combobox
  INSERT INITIAL LINE INTO lt_values INDEX 1.
 
* insert values from domain
  SORT lt_values BY value.
  CREATE OBJECT rv_valuehelp_descriptor TYPE cl_bsp_wd_valuehelp_pldescr
    EXPORTING
      iv_source_type     = 'T'
      iv_selection_table = lt_values.
  DATA:
    lt_values TYPE bsp_wd_dropdown_table.

  SELECT domvalue_l ddtext
    INTO TABLE lt_values
    FROM dd07t
    WHERE domname = 'YOUR_DOMAIN_NAME'
      AND ddlanguage = sy-langu.

* insert an empty value into the combobox
  INSERT INITIAL LINE INTO lt_values INDEX 1.

* insert values from domain
  SORT lt_values BY value.
  CREATE OBJECT rv_valuehelp_descriptor TYPE cl_bsp_wd_valuehelp_pldescr
    EXPORTING
      iv_source_type     = 'T'
      iv_selection_table = lt_values.

You also have to redefine the P-Getter of the field to set the field’s type. Paste the code below to set it to a ComboBox.

  CASE iv_property.
    WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
      rv_value = cl_bsp_dlc_view_descriptor=>field_type_picklist.
  ENDCASE.
  CASE iv_property.
    WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
      rv_value = cl_bsp_dlc_view_descriptor=>field_type_picklist.
  ENDCASE.

Komentowanie jest zakończone.