It’s very unclear to me what the OP is actually trying to accomplish here and it seems all sorts of wrong. BUT I want to make something very clear to anyone who might stumble upon this thread:
There is no reason, when building one’s own plugin – NO REASON AT ALL – to use get_object_from_id()
. If you are building your own plugin and using this, you are doin’ it rong.
The only use case for get_object_from_id()
is if you are duplicating Mishav’s “Server Script” plugin idea (whereby they let a Bubble user enter some code which then gets eval’ed in the SSA). Because there’s no way of sending an actual Thing from the text field for the code, this function would be necessary for taking unique ID’s (which can be put into the text field) and reconstituting them into Things. And I suspect Misha probably specifically requested this function to make the Server Script plugin viable. (Although there is probably some similar function used by Bubble in rehydration.)
NOW, if you are building a plugin for yourself or for other Bubble users, you DO NOT SEND THINGS TO THE PLUGIN AS UID’S - you send them as the Things themselves!
For example, as in List Popper:
And now, in your plugin, “data_source” will be a Bubble List
object which you can then turn into a JavaScript array using its .get()
method. If the type of that list is some Thing, the contents of that array will be an array of other Bubble objects that are Things. It has a listProperties()
method for inspecting what fields (properties) the Thing has and a .get()
method on it to get the field values.
When we send Things back to Bubble (from an SSA) we do in fact represent them as their unique ID’s, but we do not send that string or array of strings to a text
type output/exposed state, we send that to a state of type the Thing
type. And when Bubble receives this it rehydrates those UID’s back into their constituent Thing objects.
Again, as in List Popper:
tl;dr get_object_from_id()
is not for use in “proper” plugins
EDIT: But that one-line reducer for getting the first level of properties from a list of things is pretty , Bubble support! There is a bug in it, though, it means to be like this:
var result = list.get(0, list.length()).map(item => item.listProperties().reduce((object, property) => (object[property] = item.get(property), object), {}))
result will be an array of objects that are the Things, where we have get()'ed the first level of their properties, like so:
(The error was that the reducer in their jotted down code was just object[property] = item.get(property)
, but while that does something (assigns the value of the property to object), an assignment statement returns undefined, so we need to return (to the reducer) the updated object, hence: (object[property] = item.get(property), object)
in my modified version above.)