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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Filter in an for

tenegabi
6-Contributor

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
 
 
1 ACCEPTED SOLUTION

Accepted Solutions
tenegabi
6-Contributor
(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
6-Contributor
(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.

Top Tags