18
Views
7
Comments
Solved
How to set and get list of structure from a JavaScript node?
Application Type
Reactive
Service Studio Version
11.55.47 (Build 64439)
Platform Version
11.38.0 (Build 45971)

Hello, I am new to OutSystems and is trying to experiment a little.

When I tried to send and get a list of structure, I could not, as OutSystems JavaScript widget only accepts simple data type.

So is there is anyway to send and receive a list from a JavaScript node?

2025-01-24 02-53-49
Mustafa Emad Shaker
Solution

Well, this is a quite interesting topic @Hossam Ghonim, however, I do not think there is a direct way to use lists with a JavaScript node. But we may use a workaround to send and get lists form JavaScript to OutSystems.

Setting Using Objects

Assuming we have an structure like this, a football player structure:

-- Name
-- Age
-- Sign Date
-- Salary
-- Is Retired

We can convert this Structure to an Object and send it to JavaScript node.

However, I do not recommend this method as the converted object will be very complex. Here is a screenshot for the generated object by this method:

Note that this example is for a simple structure  not a list of structure. In case of a list, it would be more complicated. So this is not a recommended practice.

Setting Using JsonSerialize

Convert your list to a Json string using JsonSerialize, and send this string as an input to the Js node.

In the Js node, convert the Json string to a JavaScript array using "JSON.parse()" method.

However, you may need to use a "reviver" function to parse the dates in the Structure.

Here you can see that the array of objects were created clear. So I recommend this method.

Getting Using JsonDeseralize

Assuming you have an array of the same object, and want to export it from the Js node, we are going to use "JSON.stringify()" method.

You may need to use "replacer" function to adjust any date or datetime so that it may be parsed by OutSystems. To test it, make sure that you date or datetime string value can be parsed by "TextToDate" and "TextToDatetime" in OutSystems.

Before passing the Json string to JsonDeseralize node, make sure that the Structure matches object coming out of the Js node, and that each attribute has the name of the Json attribute defined in it.

You can find a demo for getting and sending lists and objects to Js node, in the file attached.

Hope this was of help.

ObjectsAndLists2Js.oml
2025-04-17 07-20-44
Hossam Ghonim

Thanks @Mustafa Emad ShakerJson seralize and deseralize did solve the issue. But I wonder why this functionality was not added by outsystems!!

2025-01-24 02-53-49
Mustafa Emad Shaker

I did wonder the same, and went to the Ideas' section, but found several persons who posted about this issue.

But I think Nuno Reis answered this question below.

2026-01-28 16-57-48
Mihai Melencu
Champion

Hi @Hossam Ghonim ,

To pass a list into a JS node, first use JSONSerialize  to convert it into JSON text and map that into a Text input parameter for the JS node. 

Inside the JavaScript node, read it with JSON.parse()  .

To return a list from JavaScript, do the reverse: build your list in JS, convert it with  JSON.stringify() assign it to a Text output parameter, then use JSONDeserialize to convert that JSON string back into your structure list. 

2025-04-17 07-20-44
Hossam Ghonim

Thanks @Mihai Melencu for sharing this info.

2016-04-22 00-29-45
Nuno Reis
 
MVP

Hello.
Everytime that question pops up, the answer is to serialize/deserialize with JSON so it can pass as a string.


https://www.outsystems.com/forums/discussion/55986/list-in-javascript/


https://www.outsystems.com/forums/discussion/68477/how-to-use-a-text-list-as-input-to-javascript/


https://www.outsystems.com/forums/discussion/84491/passing-list-as-input-of-javascripts/


https://www.outsystems.com/forums/discussion/66982/best-method-to-convert-a-list-into-javascript-array/


https://www.outsystems.com/forums/discussion/97518/how-to-output-javascript-as-a-list/


You get the point. 

It is possible to do it with some variations, but it will depend in your use case,

As a general rule, OutSystems structures are supposed to be used in OutSystems and JavaScript structures in JavaScript. Data between them should be some configurations or results of operation,  not the full dataset.

2025-04-17 07-20-44
Hossam Ghonim

Thanks Nuno Reis for sharing this info.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.