How to return a custom data type in a plugin action?

I’m currently struggling with something which isn’t supposed to be so hard.

In the plugin I’m building, I’ve got an action which is supposed to return an object. I’ve defined this object as a type “Test” which has two attributes: “text” (Text) and “id” (Number).

The only thing I try to do is to return a Test Object but Bubble doesn’t seem to get it.

My question is how am I supposed to format the result so that Bubble matches the type “Test” of the object?

I came up with this …

function(properties, context) {

    return {test: {
        "text": "this is a text",
        "id": 123}

… which is not working :no_mouth:

1 Like

Bubble supports returning an object from a server-side action (the properties of which are defined in the Retuned values section above the Action code section depicted in your screenshot), but you can’t define the “type” of the returned object.

Also, it looks as though you might have used the Fields (inputs) section to define your outputs (Returned values).

What do the Fields and Returned values of your action look like?

p.s. This post probably belongs in the Plugin Builders section of the forum. I think this section is more for those needing help using plug-ins.

My bad for the wrong section.

Actually I think it is possible to define the type of a returned object on the app, but not in the plugin editor.

For instance, in the plugin editor I have defined a key as an APP TYPE. This is indeed an input because I need to setup the APP TYPE inside my APP.

As you can see on the screenshot below I’ve defined the desired returned Type as a “Test” object. Thus, I guess I need to return an object with the same attributes as my “Test” data type to be able to process them as a Bubble Object.


However, I don’t manage to return any data…

That appears to me to be what you’ve defined in the Fields section, and that’s an input for the action. When defining Returned values, you should see only Bubble native types.

If you are really really sure that you need to define a custom return type, there is a sophisticated hack, but bear in mind that it is not sanctioned by Bubble and is not for the uninitiated. I would strongly urge you to at least get one normal server-side action working and understand it first.

Ok! Thank you for the link, I didn’t know there was a hack needed to pass a custom Type inside a plugin.