cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Filter in an for

tenegabi
12-Amethyst

Filter in an for

Hello there,
I have this code: 
for (var x = 0; x <me.kpis.length; x++) {
var line=me.kpis[x].Line;
var json_yt = Things["Name of Things"].GetKpis({
Lines: line,
_timeOption:"Yesterday"
});


var json_yt = Things["Name of Things"].GetKpis({

Lines: line,
_timeOption:"All month"
});

if(line.includes("line1")) {

var kpis_value_yt_value =json_yt.array.filter(x=>x.kpis)[0]["kpis"];

 

I want to get Kpis from json_yt but when I try to get data from there I have a message: 

 Error executing service Test. Message :: TypeError: Cannot read property "kpis" from undefined - See Script Error Log for more details.
 
When I read this service : 
var result = (json_yt);
I have an array with all data. 
When I try to do this with _timeOption "All month" it works, only with Yesterday it wont works. 
I dont know if I made a mistake or the platform have some problems. 
Can someone help me?
Thanks
 
 
ACCEPTED SOLUTION

Accepted Solutions
tenegabi
12-Amethyst
(To:tenegabi)

I found a way to filter. 

if (json_yt.array[0] == undefined ) {
continue;}

I make an if and for me it was a problem because always I put null, but must check what the value return your array. 

Thank anyway.

View solution in original post

1 REPLY 1
tenegabi
12-Amethyst
(To:tenegabi)

I found a way to filter. 

if (json_yt.array[0] == undefined ) {
continue;}

I make an if and for me it was a problem because always I put null, but must check what the value return your array. 

Thank anyway.

Announcements


Top Tags