Pass Object Javascript Block (Mobile)
Question

How to pass a Javascript Object to a Javascript Block like a Json

Hi Filipe,


One way is to convert a structure do JSON, pass it as a Text parameter and then parse inside the block:



Cheers,

Renato


Filipe Lourenço wrote:

How to pass a Javascript Object to a Javascript Block like a Json



So although the javascript block has the Object type is not possible to pass as an object

Filipe,


I could pass and use an Object like so (TestStruct is an OutSystem structure):


The structure is:


Filipe Lourenço wrote:

So although the javascript block has the Object type is not possible to pass as an object



Where is the Object coming from originally?

For example... in the MediaWithCompression Plugin Wrapper I created... I created a new Media object.  I needed this Media Object in other Javascript Modules and I couldn't see a way of passing an Object out via a parameter.

So... I used "this".  E.g. 

var mediaRec = new Media(... all the media stuff...);

this.mediaRecObject - mediaRec;

Then, in another Javascript Module I could do this...

var mediaRec = this.mediaRecObj;

Essentially, this is creating a global namespace variable containing the Object.


faced the same problem. Solution quite easy: use toJS():
$parameters.TestStruct.toJS().nameAttr

In OS 11 this doesn't work any more :(

But you can use for example $parameters.Object.data.data._values to get access to values if list passed as object


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