Skip to Content

Smartfield -dropdown annotation help - only ID no description


I have followed every guide and discussion, but my problem still persists, so I seek out help here myself.

I have implemented annotation in frontend for SmartField dropdown.

 <Record Type="Common.ValueListParameterOut">
   <PropertyValue Property="LocalDataProperty" PropertyPath="CountryOfOrigin"/>
  <PropertyValue Property="ValueListProperty" String="CountryId"/>
   <Record Type="Common.ValueListParameterDisplayOnly">
    <PropertyValue Property="ValueListProperty" String="CountryName"/>

Indicated Smartfield configuration as dropdown and displayBehavior as idAndDescription, but all I get inthe output is Id and instead of description -> again ID!

Has someone had the same problem or has any idea how and what to change?


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Jun 26, 2019 at 11:32 AM


    For others who read it later, here is the solution to this problem.

    You need to add the below annotation to the key property which directs it to the description property for value help entity.


    I created a tiny helper method to ease it for future so that we pass just value help entity name, entityset name, inout property name and its description property name.

      METHOD set_as_dropdown.
        DATA: lo_entity_type TYPE REF TO /iwbep/if_mgw_odata_entity_typ,
              lo_property    TYPE REF TO /iwbep/cl_mgw_odata_property,
              lt_property    TYPE TABLE OF /iwbep/med_external_name,
              lo_annotation  TYPE REF TO /iwbep/if_mgw_odata_annotation,
              lo_entity_set  TYPE REF TO /iwbep/if_mgw_odata_entity_set.
        lo_entity_set = model->get_entity_set( iv_entity_set_name = i_entityset ).
        IF lo_entity_set IS BOUND.
          lo_annotation = lo_entity_set->create_annotation( 'sap' ).
          lo_annotation->add( iv_key = 'semantics' iv_value = 'fixed-values').
        lo_entity_type = model->get_entity_type( iv_entity_name = i_entity ).
        IF lo_entity_type IS BOUND.
          "For this property (dropdown value), we define its "Description"
          lo_property ?= lo_entity_type->get_property( i_key_property ).
          lo_annotation = lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' ).
          lo_annotation->add( iv_key = 'text' iv_value = i_desc_property ).
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.