Skip to Content

Fetch the first item's value of the list | oData v4, SapUi5 or OpenUi5

Currenet Ui5 Version used 1.46.12

What is Required?

Is to Fetch the first item's value "EventDate" of the list array which is received from the oData(v4) response.

View Code

<layout:VerticalLayout binding="{/Logs}">
    <Text text="Latest update"/>
    <Text id="LastUpdatedSynchronizeDateStringText"
          text="{EventDate}"/>
</layout> 

Batch request response (oData v4)

{
 "@odata.context":"http://localhost/odata/$metadata#Logs","value":[
    {
      "LogId":12512,"ErrText":"end","EventDate":"2017-05-11T07:10:44Z","Location":"OEN","Result":0
    }
  ]
}

Tried & Failed:

<Text id="Last..." text="{EventDate}"/>
<Text id="Last..." text="{0/EventDate}"/>
<Text id="Last..." text="{0.EventDate}"/>

Error message is "Failed to drill down"

Thank you

Saanvi S

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Oct 12, 2017 at 10:04 AM

    Hi Sanvi,

    In the code you didn't closed the <layout:VerticalLayout> tag properly,

    binding to the first item of a collection, try some thing like shown below

    <layout:VerticalLayout binding="{/Logs/0}">
    	<Text text="Latest update"/>
    	<Text id="LastUpdatedSynchronizeDateStringText" text="{EventDate}"/>
    </layout:VerticalLayout>
    Add comment
    10|10000 characters needed characters exceeded