Juan Pieterse
Posts: 0
Joined: Sat Apr 25, 2015 1:47 pm

Mapping specific element in array

In the example below I'd like to map a value from a service response to a local storage variable.
I KNOW the service response gives me an array, but how do I get a handle on the FIRST FirstName in the service resonse's array.
(In this case I'm only interested in the FIRST element of the array, as I'm only expecting one value to be returned)

I guess I need to enter the JS section of the storage input, but I don't know what (input) variable to address for this. The javascript should basically return
the first FirstName in the "input" array.

Help would be greatly appreciated :)

Image

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Mapping specific element in array

Hello Juan,

You are right, you should use JS.

Add handler on service success event, full service responce will be able in variable "data".

Juan Pieterse
Posts: 0
Joined: Sat Apr 25, 2015 1:47 pm

Mapping specific element in array

Cool! - Is there any code examples somewhere?
How would I, for instance get a handle on the first 'FirstName' variable?
Thanks for the quick response.You guys are great!

Juan Pieterse
Posts: 0
Joined: Sat Apr 25, 2015 1:47 pm

Mapping specific element in array

Cool! - Is there any code examples somewhere?
How would I, for instance get a handle on the first 'FirstName' variable?
Thanks for the quick response.You guys are great!

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Mapping specific element in array

Use JS below to get FirstName of the first item:
var FirstName = data[0].FirstName;

Return to “Issues”