Mobile app, Javascript Output parameter problem

I have a Javascript node inside a client action in a block. Inside this Javascript i have a sentence like this

$parameters.out = value;

But the out variable is always empty. It seems that the value is never assigned to the javascript output variable.

Must i do anything special to assign values to javascript output variables ?

Thanks in advance

The parameter is well assigned, could be the missing brackets enclosing the else.



Hi,

Have you read this document?

Regards,

Nuno Verdasca


Hi Francisco,

Is the function called? Use console.log to help you to debugging. Something like this before the set output:

console.log("my output", numberOfSelectedPoints);


After that, run the application in the browser, and check the console of the browser:

If nothing appears, you need to confirm if the function is called.


Regards

Nuno Miguel Verdasca wrote:

Hi,

Have you read this document?

Regards,

Nuno Verdasca


Hi Nuno, this makes all sense.

The assignment is done inside a function that is a drag&drop event handler. The problem is that if i execute $response() inside this function, the drag movement stops, any other idea to pass de value to the output parameter ?

Thanks in advance


PD: I tried mutation observer with no success...


You can do that by creating a local variable associated to an input box for example, and then with JavaScript  change the value of that input. Then you just need to use the AjaxRefresh widget to get your js value at your local variable.


Otherwise, or other possibility to solve your problem:

In the first case, the better (and by far the easiest) would be to create a Structure that mimics your List record, adding the field to store the nested object (data type itself a list of another structure or structure). You create a local variable of type List Structure and fill the list with the data from your table, leaving the new field (not in the table) empty. Than you fill this field (list/structure) with data from the second list/table/record.

Than you do a single JSONSerialize and gets as result a fully working JSON formatted string with nested JSON objects.

If this is not what you want, but rather only "append" more elements, you just use the ListAppend to append them to the list before serializing. Again, you do the JSONSerialize only once.

It is easier (or at least more understandable and obvious) than manipulate strings.


Last alternative, try see this OutSystems Document: Extend Your Mobile App Using JavaScript


Hope it can help you.
Cheers,

Nuno Verdasca