Skip to main content

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+= databi]/'ID'];
}

 

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 = datati]i"id"];
alert(myID);
}

What are the results?

Cheers!


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. 

 


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]a"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


Hi @nimesha.kalinga,

 

Thanks, that worked! 


Reply