I am still new to OutSystems and I miss the logic behind passing specific objects to a Javascript widget.
I have 2 basic Screen like in the tutorial for the creation of your first mobile app: one screen lists tasks and the second one, one you selected the task, will display the details for that task.
Now, I would to pass to a Javascript widget the entire database row of the selected task but I am stuck here. Let's say the "TaskDetail" screen displays the entire row showing data as GetProfileById.List.Current.Profiles.field1, GetProfileById.List.Current.Profiles.field2, etc., can I pass an object to the Javascript that contains field1, field2, etc ?
I hope I was clear enough.
Hi Luca,Here's what you should do, or at least one of the ways to achieve it.
1. Use the JSON Serialize widget to serialize GetProfileById.List.Current.Profiles.
2. Right after, place your javascript widget with a text input parameter, and pass in the result of the JSONSeralize
3. Inside the javascript, parse the JSON, storing it in a variable of your naming choice.
4. Now you can access your data from inside the javascript by typing VARIABLENAME.NAMEOFATTRIBUTE, like this screenshot exemplifies:
Let me know if this helped and, if so, mark it as solution so more people can refer to it.
Cheers,
Paulo
Hi Luca,
you can't pass outsystems entities or structures into the javascript widget as that structure.
You have these options
Which one of these to use, will depend on what exactly you want to do with the data inside your javascript, can you elaborate further why exactly you need that row of data in your javascript ?
Dorine
Hi,
Yes, you can use your local record type variable in JavaScript widget. Inside the JavaScript widget, define input parameters that represent the specific objects you want to pass. For example, if you want to pass an object representing a user profile, you can define an input parameter like UserProfile of the appropriate data type.
Thanks,
Ok, but what I miss is how to assign the current database row to the input variable of the script.
You can find here:
https://success.outsystems.com/documentation/11/reference/outsystems_language/data/handling_data/variables/local_variable/
You can create a local record variable for your DB record and this variable can be used as input variable.
That's what I am not confortable with. Could you please point me to where I can read more on how to create such local variable and assign an entire database row to it?
Thanks both Paulo and Dorine. JSON Serialize widget was indeed the solution to my problem.