Extracting return of a plugin and saving to database

I have this code in my plugin:

    let parsedBody = json.parse(requestSent.body);
    
    parsedBody.message.data.forEach(orderInfo => {
        ordersInfo.push(`"{
        "orderId": "${orderInfo.orderId}", 
        "actualOrderId": "${orderInfo.actualOrderId}",
        "campaign": "${orderInfo.campaignName}",
        "orderStatus": "${orderInfo.orderStatus}",
        "cardType": "${orderInfo.cardType}",
        "cardLast4": "${orderInfo.cardLast4}",`)

    return {
        orders_info: ordersInfo
    }

it’s returning the info well. But the problem is, the return type I can only choose for the plugin is limited to basic data types. I chose a list of text.

I can’t return objects. I have created a database with these info:

I need to be able to somehow map the data I retrieved from the plugin onto the database.

The mapping will happen in the WF, not in the plugin. A plugin is not related to a specific app, so there’s no way to select any datatype from your own DB directly into a plugin. your plugin will return all fields like “campaign” as a type of text and in the WF you will use result of step 1’s campaign to map it to the item your want to create or update.

Custom type can be created using API Connector.

Are you doing API Call into your plugin? If yes, why you don’t use API Connector?

There’s a field that is producing unexpected results.

For example:

{“orderId”: “123”,
“campaign”: “hello”,
“items”: {
“1”: {
“productId”: “1”,
“name”: “world”,
}}

when I try to retrieve it, it looks like:

Now, I don’t know why they made the supposedly clear list be an object, but it is what it is. And somehow, bubble can’t recognize the “items” key and it jumps straight to the productId key.

Yes. This is a kind of Json that you cannot use in API connector because it display object into a dictionnary. Consider creating a custom type in your plugin using API connector in Plugin and use data type to return the converted json

1 Like