Using a Record List variable in JS

Using a Record List variable in JS

  

Hi,

I integrate my Outsystems app with a morris.js charts and I can work fine with this. The problem is, example:

SyntaxEditor Code Snippet

"<script>
    new Morris.Line({
      // ID of the element in which to draw the chart.
      element: '"+Chart.Id+"',
      // Chart data records -- each entry in this array corresponds to a point on
      // the chart.
      data: [
        { year: '"+DadosChart.Current.StructureChart2D.x+"', value: "+DadosChart.Current.StructureChart2D.y+" }
      ],
      // The name of the data record attribute that contains x-values.
      xkey: 'year',
      // A list of names of data record attributes that contain y-values.
      ykeys: ['value'],
      // Labels for the ykeys -- will be displayed when you hover over the
      // chart.
      labels: ['Value']
    });
</script>"

in data, I want work with a RecordList... How I can do that?


Thanks

Solution

Hi João,

Are you creating a mobile app or a web app? For web apps, Lists and Record Lists live server side, while the JavaScript lives client side. So there's no way you could access Lists from JavaScript. In your case above, you would need to iterate over the List (server side) and convert the elements to the JavaScript you need.

Solution

Hi Kilian,

Thanks for replay.

I'm working on a Web App. I came with this solution:

Create a text variable, iterate the Record List and build the array I need in text variable. Then, I use the text variable in JavaScrip ;)

This work fine.

Thanks

Hi João,

That's indeed what I proposed. Note that, depending on the size of the list and the number of concatenations, it may be better for performance to use a StringBuilder from the Text extension. But for small lists you won't see a difference.