Skip to Content
0

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

Oct 12, 2017 at 06:12 AM

46

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Vedaradhya Agrahar Oct 12, 2017 at 10:04 AM
0

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>
Share
10 |10000 characters needed characters left characters exceeded