Solution to using RPC with Collections

If you’ve tried to pull in RPC data into a collection type, you’ll have noticed that it doesn’t work. Instead what you can do is to wrap your RPC return value in a collection.

This is the RPC config. The critical part is the wrapper which nests our output in the required format for a collection instead of returning the output directly.

{
    "url": "/forms/{{parameters.formId}}",
    "method": "GET",
    "response": {
        "iterate": "{{body}}",
        "output": {
            "name": "{{item.id}}",
            "label": "{{item.label}}",
            "type": "text"
        },
        "wrapper": {
            "type": "collection",
            "name": "data",
            "spec": "{{output}}"
        }
    }
}

And then this is the interface:

[
	{
		"name": "event",
		"type": "text",
		"label": "Event Name"
	},
	{
		"name": "orgId",
		"type": "text",
		"label": "Org ID"
	},
	{
		"name": "sentAt",
		"type": "timestamp",
		"label": "Trigger Sent At"
	},
	"rpc://getFormFields?formId={{webhook.resourceId}}"
]

I’m sharing this because I wasted hours trying to just pass the list of fields as spec to a collection type which seems to not be supported. Hopefully this helps somebody!

6 Likes

Hi @lexitay,

Creating custom apps can be a hassle sometimes, it is a lot of trying and failing until you find a solution. Thanks for sharing this piece of knowledge with the community.

Henk

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.