Anyone know of a way to do this entirely client-side?
In other words, while the custom object in the technique described above can be referenced and displayed client-side, it seems it must be generated server-side. It would be great if there was a way to make a custom object available in the editor without hitting the server.
Publishing a state does not appear to be an option, as it seems youâre limited to Bubbleâs built-in primitive types (no âApp Typeâ available); and client-side actions (element or plug-in level) donât have return values.
For instance, if you have a parameter that should contain a date value, you cannot send an empty value for that parameter in server-side actions. Youâll receive an error.
The piece I missed was that an âINPUTâ (field / property) of type âApp Typeâ must first be defined before that type is available as an âOTUPUTâ type (the context being an exposed state in the case below).
As for using it in a published plugin, Iâll have to give that some thought. I generally eschew detailed docs in favor of a friendly and approachable UI. In this case, however (and since the audience is a Bubble dev and not an app end user), I might have to reconsider. Despite it being a bit convoluted (and confusing at times) to set up, the benefit gained in the editor might make it worthwhile in some cases.
As @AliFarahat said, though, I hope Bubble makes it easier to do this in the future!
Thanks again, @lottemint.md, for working this out and posting it!
When used client-side in this way - i.e. as an exposed state thatâs a custom type - it requires the user (Bubble dev) to configure the field (choose the custom type) in the properties editor. Is there any way around this? Or has anyone come up with a way to automatically set the âApp Typeâ field in the properties editor?
Ideally, user intervention wouldnât be required, but I see no way around it. Anyone have any ideas for an elegant solution aside from using the âdocumentationâ for the field to instruct the user to choose the correct item?
Hi, just wondering does Step 3 work for client side element plugins?
Specifically, am trying to make a whole object to return to Bubble using instance.PubllishState() for client-side plugin and was wondering if the p notation works for a client side object as cannot seem to get it to work
thank you
(for reference)
Step 3:
a) Go to the server-side action to insert the following code: function(properties, context) {
Step 3 is required, but itâs a bit different for client-side. Instead of âGo to the server-side action to insertâ the code, you simply expose the object using instance.publishState().
First off, just to cover the bases, step 1 is also a bit different for client-side. You donât create a field for a server-side action; but rather, as noted here, you must define a property editor field of App Type to allow the user (Bubble dev) to choose your custom type.
Then, define your exposed state to be of that type (which the user is free to choose but which you must âensureâ they choose correctly - typically via the field documentation). Otherwise, your custom object wonât be available in the Bubble editor.
Secondly, your out variable is a list of custom objects, which should be fine if thatâs what you intend (although it must match the definition of the exposed state).
What does the JSON for your API definition look like?
What, if any, errors are you seeing in the console?
So I just can seem to get the object formatted correctly⌠Do you happen to have an example of a object that you send back via instance.PublishState() ?
this would help immensely
Here is my code:
var out = [{
_p_name: âMagicâ,
_p_age: â32â
}];
instance.publishState(âoutputâ, out);
Your screenshot shows the definition for a âThingâ in your DB, and your DB has nothing whatsoever to do with this approach (Bubble hack) for making a custom type available in the Bubble editor.
I think you need to walk carefully through Step 2 as described in the original post.
Yes. Youâre missing the fact that Step 2 is nothing more than a bunch of âhoop jumpingâ required to âmake Bubble aware ofâ your custom type - whether you wish to use it server-side or client-side.
EDIT: Again, I just want to emphasize that this is a âhackâ, and a rather sophisticated (albeit very useful) one at that.
Its works!!! You were right about the super-hack to create a âcustom output objectâ⌠then using the p notation to make the JSON object does the trick. I thought step 2 was for server side, but I see it is the hacky-step to create a custom object for output that can be used with the instance.Publish state
Thank you very much for your time to help me understand this work-around-hack
Every instruction in this list works for me, except the very last one, where I do not see the Plugin Action as a valid selection within a workflow action.
I even went so far as to recreate this Test action identically.
The funny thing is this Plugin already has one action that I do see, but this action I do not.
Any idea what critical step Iâm missing?
Later edit: It appears I was merely impatient. I took a 30 minute break, and when I returned, the âmissingâ Plugin Actions were no longer missing.