Skip to main content
Question

Handling dynamic outputFields in performList and perform methods

  • April 4, 2025
  • 1 reply
  • 12 views

Is there a way to handle outputFields dynamically? I tried to do it this way, but it didn't work:

 

const outputFields = [];const perform = (z, bundle) => {    return [bundle.cleanedRequest];};const performList = (z, bundle) => {    const options = {        url: 'https://webhook_url',        method: 'post',        hook_id: {            'Authorization': 'Bearer ' + bundle.authData.access_token,        },        body: {},    };    // This part will be generated through a mapping in JSON    outputFields.push({        key: 'form',        label: 'Form',        type: 'string',    })    return z.request(options).then((response) => {        return response.data    });};
Did this topic help you find an answer to your question?

1 reply

Sorry I forgot to format the code, here is the properly formatted code:

const outputFields = [];
const perform = (z, bundle) => {
    return [bundle.cleanedRequest];
};

const performList = (z, bundle) => {
    const options = {
        url: 'https://webhookurl',
        method: 'post',
        headers: {
            'Authorization': 'Bearer ' + bundle.authData.access_token,
        },
        body: {
            form_id: bundle.inputData.form_id,
        },
    };

    // Here I'm using a simple value, but I plan to do it by mapping the JSON
    outputFields.push({
        key: 'form',
        label: 'Form',
        type: 'string',
    })

    return z.request(options).then((response) => {
        return response.data
    });
};

 


Reply