Hi,

I have Written my javascript in expression and set its escape content to NO, and I have one local variable say LatlongList which is returning the list of latlong fetching from database.

now, I want to iterate LatlongList into the javascript code which is written in expression.

how I can iterate the list please suggest me.


Convert your ousystem list to a outsystem string that resembles a Javascript list

Use String Concat within Expression to embed the list within the Javascript expression.

Use for loop in Javascript to loop over it.


Hope this helps

1. Convert list to JSON string in OutSystems.

2. Pass string to JavaScript

3. Use JavaScript JOSN.parse() function to generate a JSON object from the string

4. Iterate the list elements in the JSON object

With jQuery

$.each(obj, function(key, value) {
    console.log(key, value);
});

Or with hstandard javascript

for (var prop in p) {
    if (!p.hasOwnProperty(prop)) {
        //The current property is not a direct property of p
        continue;
    }
    //Do your logic with the property here
}

Daniël Kuhlmann wrote:

1. Convert list to JSON string in OutSystems.

2. Pass string to JavaScript

3. Use JavaScript JOSN.parse() function to generate a JSON object from the string

4. Iterate the list elements in the JSON object

With jQuery

$.each(obj, function(key, value) {
    console.log(key, value);
});

Or with hstandard javascript

for (var prop in p) {
    if (!p.hasOwnProperty(prop)) {
        //The current property is not a direct property of p
        continue;
    }
    //Do your logic with the property here
}

Thank you so much its working for me.


Hi Gautam,

You're welcome.

Have a nice day :)

Regards,

Daniel