I’m trying to extract a Current User’s name through a console.log(???); to begin with.
I thought a Bubble thing was an object, but it doesn’t seems to be, because it throws a lot of errors when I try to manipulate a Thing as an object, and currently console.log’ing it returns this:
{…}
__original: function __original()
get: function get()
listProperties: function listProperties()
__proto__: Object { … }
Yep.
Every thing is an object.
And in a plugin, when you want to get a value stored in a thing’s field, you use:
console.log(properties.someThing.listProperties()); // Will list fields for me
console.log(properties.someThing.get("Created Date")); // Will return the date
console.log(properties.someThing.get("lista_de_texto_list_text")); // Will return the list of texts (an array)
Push a value where? Into the database inside a thing? Not through this channel, this is a getter object only. We don’t set values this way.
Bubble has some features to save to database, but none that I know of to simply shove some data into the app maker’s database without the app maker’s manual input.
Client side we can publish something into a state of an element in a page via
instance.publishState("saved_pdf", url)
and then the app maker gets the value there.
Server side we use “Result of step X…”, when step X is the step that runs the server side workflow, like this:
“ssss” is my server side action. This is what I know that works. Since Bubble doesn’t provides setter functions… I think this is it.
Edit: In short, no. We can’t directly touch the database, but apart of native workflows we can touch it through the Data API, but it’s much more complicated on my view.
Hmm? Current User is always available via context:
context = {
currentUser: {
get: function(fieldName: String) - returns the value of a field for the object
listProperties: function() - returns an array of the different fields you can access
}
jQuery: main jQuery object
uploadContent: function(fileName: String, contents: Base64 String, callback: function(err, url), [attachTo])
attachTo: optional parameter to attach the file to. It has to be a thing in Bubble
async: call context.async with a function that kicks off an asynchronous operation,
taking a callback taking (err, res). Returns res or else throws error.
keys: Object with Keys defined in the Plugins Tab
onCookieOptIn: function(callback: function - runs callback once cookies are allowed (immediately if already accepted)
reportToDebugger: function(message: String) - reports an error to the debugger
}
Hey @keith, would you mind elaborating what you wrote?
I am writing a javascript script which has to call an API in my app and supply current user’s id to it.
I am guessing what you have written would be useful to me, but I am unable to understand what exactly I need to do. Is “context” an in-built keyword in javascript? Is currentUser a variable that is available to us in the scripts? What you have written is kind of pseudo code I think. Could you share what could be the code snippet exactly? I am not using jQuery by the way.
Are you suggesting that I write the code below and I’ll get user’s email in “currentUser”?