The Community will be temporarily unavailable starting on Friday February 28. We’ll be back as soon as we can! To learn more, check out our Announcements blog post.
Apr 21, 2023 03:54 AM
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:
As I am new in coding, Can you tell what is missing?
Solved! Go to Solution.
Apr 21, 2023 04:45 AM
In scripting, a view does not have a “fields” property listing the visible fields. Thus the lines containing view.fields.length and view.fields[i] won’t work.
You will need to hardcode the list of fields that you want.
Apr 21, 2023 03:56 AM - edited Apr 21, 2023 03:59 AM
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) } );
Apr 21, 2023 04:45 AM
In scripting, a view does not have a “fields” property listing the visible fields. Thus the lines containing view.fields.length and view.fields[i] won’t work.
You will need to hardcode the list of fields that you want.
Apr 21, 2023 04:54 AM
OK I undertand a bulk field view export is not possible.
@kuovonne thank you very much!