Solved

Create a list of variables for FSM mobile

  • 28 September 2022
  • 4 replies
  • 50 views

Badge +6
  • Do Gooder (Customer)
  • 11 replies

Hi All,

 

I’m struggeling to create a list via a Mobile Client Script.

  • I succesfully recieve a Object with data via getDBValues, but I only need one item from that object.
  • So I created a for loop, to go trough the object and store the value in a String, Array or Object (doesn’t matter).
  • Creating a new Array or a Object seems not to work for mobile
  • Als simply extending a var via the += method also not working.

Example:

var data = getDBValues(stringFormat("SELECT id FROM database_table WHERE type = 'placeholder'"));
var arr = new Array();
var list = ‘’;

for(var i=0; i < data.length; i++) {    
   arr.push(data[i]['ID']);
   list+= data[i]['ID'];
}

 

icon

Best answer by nimesha.kalinga 28 September 2022, 13:02

View original

4 replies

Userlevel 6
Badge +18

Hey @drooij 

Can you try the following?

In the for loop, try printing the values. And remove the array creation, for now

for(var i = 0; i < size(data); ++i) {
var myID = data[i]["id"];
alert(myID);
}

What are the results?

Cheers!

Badge +6

Hello @Shneor Cheshin 

It will show the ID’s, but now the variable will only contain the last value from the loop. 
In the end I would like to have the variable “myID” containing all ID’s from the loop. 

 

Badge +3

Hello @Shneor Cheshin 

It will show the ID’s, but now the variable will only contain the last value from the loop. 
In the end I would like to have the variable “myID” containing all ID’s from the loop. 

 

 

Hi @drooij 

 

Can you try the below,

var strListOfId = "";

for(var i = 0; i < size(data); ++i) {
var myID = data[i]["id"];
strListOfId = stringFormat("{0}, {1}", strListOfId, myID);
}

alert(strListOfId);

apologize for the syntaxes as i haven’t had time to test it. But your requirement should be possible with using the stringFormat function

Badge +6

Hi @nimesha.kalinga,

 

Thanks, that worked! 

Reply