Can someone point me to the simplest JavaScript example of bringing a “thing” into the “Toolbox JavaScript” as a JavaScript object and returning that JavaScript object back as a “thing” to the workflow using “Javascript to Bubble”?
I don’t know if it is simple, but you can see how this process works.
What are you trying to do?
You are absolutely right. This is how the process works with data types. The issue here is that a “thing” is an object.
I have a case of a complex calculations (looping, recursive processing, dynamic variables) and resulting decision making based on a number of the “thing’s” variables. Also the resulting changes to such a “thing”. Not a difficult task for JavaScript, next to impossible with bubble workflows, etc. So, the most logical solution is (a) bring an object (thing) to JS, (b) massage and change the object, (c) send the object back to the bubble workflow.
But you can access all the fields you want, of any object you wish, inside your JS code.
So what I mean is that an Object is formed by many information, and even if you can’t load an User inside your JS, you can load all it’s information, like name, age, email and etc…
In the end, there is no diference. You will have every information you want. To loop, search, filter and etc…
Can you give me an example of what you want to do? I may help you.
Rafael, I truly appreciate you engaging with this issue. We are developing a derivatives trading prototype. Dealing with issues like option pricing, volatility, intrinsic and time value, regulatory requirements, … Intent is to showcase 200+ formulae, most of them highly proprietary. Current data architecture (in bubble) requires more than 50 data types, averaging 70+ fields, some of them nested. This prototype needs to show correct results, but also our ability to implement new formulae and required data structures faster than anyone else. In our world, time is of essence, to the cube.
Once these data types are defined in bubble, so that we can persist them, we don’t have the luxury of redefining them (again) in JS for the purpose of calculation and decision making. So, we either bring the 70+ field thing into JS, or using bubble, in our case, does not make any sense. BTW, no fault of bubble.
Using your referenced example, we simply need a JS template where first and last line’s variables will be objects/things, if possible.
… even if JSON
Maybe?
To get all Things use a Server script with the following code JSON.stringify(get_objects_from_ids(properties.thinglist1.get(0,properties.thinglist1.length()).map((x) => {return x.get("_id")})));
and don’t forget to set Thing List 1.
See here http://forum.bubble.io/t/toolbox-server-script-reading-all-table-records/107682