Skip to Content
0

dropDownList SmartField with Annotation metadata not working

Jul 06, 2017 at 06:43 PM

178

avatar image

Hi all, please help me with a SmartField I want to configure to show a dropdownlist, I have followed the tutorials and samples but can't make it work.

This is my metadata.xml (some navigations and associations are working fine and have been omitted).

<Schema Namespace="PlantAccessModel" xmlns="http://schemas.microsoft.com/ado/2006/04/edm"
			xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
			xmlns:sap="http://www.sap.com/Protocols/SAPData">
  <EntityType Name="Vehicle">
    <Key>
      <PropertyRef Name="VehicleId"/>
    </Key>
    <Property Name="VehicleId" Type="Edm.Guid" Nullable="false" sap:label="Vehicle Id" sap:creatable="false" sap:updatable="false" sap:sortable="false"/>
    <Property Name="Plate" Type="Edm.String" Nullable="false" MaxLength="15" sap:label="Plate" sap:updatable="false"/>
    <Property Name="Contractor" Type="Edm.String" Nullable="false" MaxLength="50" sap:label="Contractor" sap:updatable="true"/>
    <Property Name="VehicleTypeId" Type="Edm.Int32" Nullable="false" sap:label="Type" sap:updatable="true" />
  </EntityType>
  <EntityType Name="VehicleType">
    <Key>
      <PropertyRef Name="VehicleTypeId"/>
    </Key>
    <Property Name="VehicleTypeId" Type="Edm.Int32" Nullable="false" sap:display-format="UpperCase" sap:text="Description" sap:label="Vehicle Type" sap:filterable="false"/>
    <Property Name="Description" Type="Edm.String" Nullable="false" MaxLength="50" sap:label="Description"/>
    <Property Name="VehicleCategoryId" Type="Edm.Int32" Nullable="false"/>
  </EntityType>
  <EntityType Name="VehicleCategory">
    <Key>
      <PropertyRef Name="VehicleCategoryId"/>
    </Key>
    <Property Name="VehicleCategoryId" Type="Edm.Int32" Nullable="false"/>
    <Property Name="Description" Type="Edm.String" Nullable="false" MaxLength="50"/>
  </EntityType>
  <Annotations Target="PlantAccessModel.Vehicle/VehicleTypeId" xmlns="http://docs.oasis-open.org/odata/ns/edm">
    <Annotation Term="com.sap.vocabularies.Common.v1.ValueList">
      <Record>
        <PropertyValue Property="Label" String="Vehicle Type"/>
        <PropertyValue Property="CollectionPath" String="VehicleType"/>
        <PropertyValue Property="SearchSupported" Bool="true"/>
        <PropertyValue Property="Parameters">
          <Collection>
            <Record Type="com.sap.vocabularies.Common.v1.ValueListParameterOut">
              <PropertyValue Property="LocalDataProperty" PropertyPath="VehicleTypeId"/>
              <PropertyValue Property="ValueListProperty" String="VehicleTypeId"/>
            </Record>
            <Record Type="com.sap.vocabularies.Common.v1.ValueListParameterDisplayOnly">
              <PropertyValue Property="ValueListProperty" String="Description"/>
            </Record>
          </Collection>
        </PropertyValue>
      </Record>
    </Annotation>
  </Annotations>
  <EntityContainer Name="PlantAccessContainer" p7:LazyLoadingEnabled="true" m:IsDefaultEntityContainer="true"
      xmlns:p7="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
    <EntitySet Name="Vehicle" EntityType="PlantAccessModel.Vehicle" sap:updatable="true"/>
    <EntitySet Name="VehicleType" EntityType="PlantAccessModel.VehicleType" sap:semantics="fixed-values"/>
    <EntitySet Name="VehicleCategory" EntityType="PlantAccessModel.VehicleCategory"/>
  </EntityContainer>
</Schema>

This is my view

<smartForm:SmartForm id="smartForm" editTogglable="true" title="{Plate}">
   <smartForm:Group label="Vehicle">
<!--	<smartForm:GroupElement>						<smartField:SmartField value="{VehicleId}"/>
	</smartForm:GroupElement>-->						<smartForm:GroupElement>
	<smartField:SmartField value="{Plate}"/>
	</smartForm:GroupElement>
	<smartForm:GroupElement>
	<smartField:SmartField value="{Contractor}"/>
	</smartForm:GroupElement>
	<smartForm:GroupElement>
	<smartField:SmartField value="{VehicleTypeId}" >
	<smartField:configuration>
	<smartField:Configuration controlType="dropDownList" displayBehaviour="descriptionAndId"/></smartField:configuration>
	</smartField:SmartField>
	</smartForm:GroupElement>
	</smartForm:Group>
</smartForm:SmartForm>

This is the result with no Dropdownlist

Any help will be welcome.

untitled.png (7.7 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Daniel Moran Jul 06, 2017 at 10:04 PM
0

The problem was here:

<PropertyName="VehicleTypeId" Type="Edm.Int32" Nullable="false" sap:label="Type" sap:updatable="true" />

I'm afraid this behavior works only with Type="Edm.String"

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hello Daniel,

I face the same problem.

In my Smart Filter, I have specified one of my filter with displayBehavior = "descriptionOnly". Its OData property is of type ="Edm.String".

I get the dropdown box. But no data is retrieved from the backend.

Any help?

Thanks in advance.

Shiny.

0
0