Skip to main content

Hi everyone!

This Script is working greate to send a webhook containing table fields in an automation.

I'm trying chaneg it to send a only fields from a specific view.

I tried to change and adjust it to fit a certain View. I added "let view = table.getView("MyView");" and changed all the Table References to View References but I get an error message:

"TypeError: Cannot read properties of undefined (reading 'length')".

As I am new in coding, Can you tell what is missing?

That is what I tried:

 

let table = base.getTable("MyTable");

let view = table.getView("MyView");

let webhookUrl = "https://hook.eu1.make.com";

let inputConfig = input.config();

console.log(inputConfig);

let queryResult = await view.selectRecordsAsync({});

console.log(queryResult);

let record = queryResult.getRecord(inputConfig.recordID);

console.log(record); let recordObject = {};

for (let i = 0; i < view.fields.length; i++) { recordObject[view.fields[i].name] = record.getCellValueAsString(view.fields[i].name) } console.log(recordObject);

let response = await fetch( webhookUrl, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(recordObject) } );


In scripting, a view does not have a “fields” property listing the visible fields. Thus the lines containing view.fields.length and view.fieldsei] won’t work. 

You will need to hardcode the list of fields that you want. 


In scripting, a view does not have a “fields” property listing the visible fields. Thus the lines containing view.fields.length and view.fieldsei] won’t work. 

You will need to hardcode the list of fields that you want. 


OK I undertand a bulk field view export is not possible.

@kuovonne thank you very much!


Reply