How to Export Rows from a Seatable Table Filtered by Formula Using Configurable Props in NodeJS Code?

like this row[“סטטוס שליחה”] && row[“סטטוס שליחה”].is(‘פעיל’);

I understand that you want to use a different filter condition instead of includes. If you want to check if a value is greater than a specific value, you can use the > operator in your formula. Here’s an example: ```
row[“AGE”] && row[“AGE”] > 30;

It seems like you want to filter rows based on the value of the “סטטוס שליחה” column, checking if it’s equal to ‘פעיל’. You should use the === operator instead of the .is() method, which doesn’t exist in JavaScript. Here’s the correct formula: row["סטטוס שליחה"] && row["סטטוס שליחה"] === 'פעיל'; This will return true if the value of the “סטטוס שליחה” column is ‘פעיל’, and false otherwise.

Thanks now I have this code that you gave me and supposed to work, but I don’t get the answer code from the API call. I want to save it in other seatable table named “לוג שליחות”.
Can you add this to the in the loop of each api request?

this is the call :
https://cloud.seatable.io/dtable-server/api/v1/dtables/{$this.base_uuid}/rows/

and token is this.base_token

import axios from “axios”;

export default defineComponent({
props: {
Instance: {
type: “string”,
label: “Greem-Api device Instance Number”,
default: “1101796351”,
},
Green_token: {
type: “string”,
label: “Green-Api Device Token”,
default: “af6a35aea200435aa8c83d09acd9f5e117cf832eb15d4b2094”,
},
students_path: {
type: “string”,
label: “Students array step path”,
},
content: {
type: “string”,
label: “Whatsapp Content Path”,
},
whatsapp: {
type: “string”,
label: “Whatsapp Number Colum Name”,
},
base_uuid: {
type: “string”,
label: “Base Uuid”,
},
base_token: {
type: “string”,
label: “Base Token”,
},
},
async run({ steps }) {

**const** apiUrl = `https://api.green-api.com/waInstance${**this**.Instance}/SendMessage/${**this**.Green_token}/`;
**const** students = **this**.students_path;
**for** (**let** i = 0; i < students.length; i++) {
  **const** chatId = `${students[i].fields[**this**.whatsapp]}@c.us`;
  **const** message = '${this.content}';

  **try** {
    **await** [axios.post](http://axios.post)(apiUrl, {
      chatId,
      message
    });

    console.log(`API call ${i+1}/${students.length} made successfully.`);
  } **catch** (error) {
    console.error(`Error making API call ${i+1}/${students.length}:`, error);
  }
}

},
});

I understand that you want to save the response from the API call to another SeaTable table named “לוג שליחות”. To achieve this, you can modify the existing code to include the SeaTable API request within the loop. Here’s the updated code: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { // …existing props }, async run({ steps }) { const apiUrl = https://api.green-api.com/waInstance${this.Instance}/SendMessage/${this.Green_token}/; const students = this.students_path; const seatableApiUrl = https://cloud.seatable.io/dtable-server/api/v1/dtables/${this.base_uuid}/rows/; for (let i = 0; i < students.length; i++) { const chatId = ${students[i].fields[this.whatsapp]}@c.us; const message = ${this.content}; try { const response = await axios(this, { method: “POST”, url: apiUrl, data: { chatId, message, }, }); console.log(API call ${i + 1}/${students.length} made successfully.); // Save the response to the SeaTable table “לוג שליחות” await axios(this, { method: “POST”, url: seatableApiUrl, headers: { Authorization: Token ${this.base_token}, }, data: { // Replace “COLUMN_NAME” with the actual column name in the SeaTable table “COLUMN_NAME”: response.data, }, }); } catch (error) { console.error(Error making API call ${i + 1}/${students.length}:, error); } } }, });

I hope you can help me with this error:
Cannot read property ‘וואטסאפ’ of undefined

this is the code:
import axios from “axios”;

export default defineComponent({
props: {
Instance: {
type: “string”,
label: “Greem-Api device Instance Number”,
default: “1101796351”,
},
Green_token: {
type: “string”,
label: “Green-Api Device Token”,
default: “af6a35aea200435aa8c83d09acd9f5e117cf832eb15d4b2094”,
},
students_path: {
type: “string”,
label: “Students array step path”,
},
content: {
type: “string”,
label: “Whatsapp Content Path”,
},
content_name: {
type: “string”,
label: “Whatsapp Content Name Path”,
},
whatsapp: {
type: “string”,
label: “Whatsapp Number Colum Name”,
},
base_uuid: {
type: “string”,
label: “Base Uuid”,
},
base_token: {
type: “string”,
label: “Base Token”,
},
logs_table_name: {
type: “string”,
label: “Logs Table Name”,
default: “לוג שליחות”,
},
},

async run({ steps }) {
const apiUrl = https://api.green-api.com/waInstance${**this**.Instance}/SendMessage/${**this**.Green_token}/;
const students = this.students_path;
const seatableApiUrl = https://cloud.seatable.io/dtable-server/api/v1/dtables/${**this**.base_uuid}/rows/;

**for** (**let** i = 0; i < students.length; i++) {
  **const** chatId = `${students[i].fields["וואטסאפ"]}@c.us`;
  **const** message = `${**this**.content}`;
  **const** message_name = `${**this**.content_name}`;

  **try** {
    **const** response = **await** axios(**this**, {
      method: "POST",
      url: apiUrl,
      data: {
        chatId,
        message,
      },
    });

    console.log(`API call ${i + 1}/${students.length} made successfully.`);

    _// Save the response to the SeaTable table "לוג שליחות"_
    **await** axios(**this**, {
      method: "POST",
      url: seatableApiUrl,
      headers: {
        Authorization: `Token ${**this**.base_token}`,
      },
     data:   {
              row: {'תשובה': response.data, 'מספר': chatId, 'שם תוכן': message_name},
              table_name: 'לוג שליחות'
               },

    });

  } **catch** (error) {
    console.error(`Error making API call ${i + 1}/${students.length}:`, error);
  }
}

},
});

this is the inputs:
Instance
1101796351
Green_token
af6a35aea200435aa8c83d09acd9f5e117cf832eb15d4b2094
students_path
[ { “_id”: “dBTHDdeSRK6XCGyInT2M6A”, “_mtime”: “2023-06-29T09:03:16.579+00:00”, “_ctime”: “2023-06-19T02:49:22.347+00:00”, “שם מלא”: “אוריאל הרצוג”, “שם משפחה”: “אוריאל”, “שם פרטי”: “הרצוג”, “וואטסאפ”: “972525289715”, “מייל”: “uriel.herzog@gmail.com”, “סטטוס שליחה”: “פעיל” }, { “_id”: “DvjsW62iSLenyLYT16dHDg”, "mtime": “2023-06-29T09:43:02.102+00:00”, "ctime": “2023-06-22T08:23:12.824+00:00”, “שם מלא”: “בניהו דיין צדק”, “שם משפחה”: “דיין צדק”, “שם פרטי”: “בניהו”, “וואטסאפ”: “972545885363”, “סטטוס שליחה”: “פעיל” } ]
content
מסר תודעת המקדש לכג סיון
content_name
כ״ג סיון
whatsapp
וואטסאפ
base_uuid
8a3c2b05-24af-4125-ba10-93ad4a730b1f
base_token
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2ODgyOTg2MjYsImR0YWJsZV91dWlkIjoiOGEzYzJiMDUtMjRhZi00MTI1LWJhMTAtOTNhZDRhNzMwYjFmIiwidXNlcm5hbWUiOiI4YmY3OGZlNjdkNDY0Mzk3YWFkY2RjYTU3ZTc2ZWRkOEBhdXRoLmxvY2FsIiwiaWRfaW5fb3JnIjoiIiwicGVybWlzc2lvbiI6InJ3In0.7lA7poczfulGjrhxNu0
-zZ69
-h6n4kiDPfWltEFXw
logs_table_name
לוג שליחות

It seems like the error is related to accessing the “וואטסאפ” property of an undefined object. Based on the provided code, it appears that the issue is in this line: const chatId = `${students[i].fields["וואטסאפ"]}@c.us`; To fix this error, you should first check if students[i].fields is defined before accessing the “וואטסאפ” property. You can do this by adding a conditional check like this: const chatId = students[i].fields && `${students[i].fields["וואטסאפ"]}@c.us`; This will ensure that you’re only trying to access the “וואטסאפ” property if students[i].fields is defined. If it’s not defined, chatId will be set to undefined, and you can handle that case accordingly in your code.

Can you add consol.log line so I can know what’s going?

Sure, you can add a console.log() statement to log the values you want to inspect. For example, you can add it before the line where the error occurs: ```
for (let i = 0; i < students.length; i++) { console.log(“Current student:”, students[i]); const chatId = ${students[i].fields["וואטסאפ"]}@c.us; // Rest of the code }

the code stops in the first student and this is the log:
Current student: {
_id: ‘dBTHDdeSRK6XCGyInT2M6A’,
_mtime: ‘2023-06-29T09:03:16.579+00:00’,
_ctime: ‘2023-06-19T02:49:22.347+00:00’,
‘שם מלא’: ‘אוריאל הרצוג’,
‘שם משפחה’: ‘אוריאל’,
‘שם פרטי’: ‘הרצוג’,
‘וואטסאפ’: ‘972525289715’,
‘מייל’: ‘uriel.herzog@gmail.com’,
‘סטטוס שליחה’: ‘פעיל’
}

Thank you for providing the log. To better understand what’s happening, let’s add a console.log() statement before and after the line where the error occurs. Update your code like this: ```
for (let i = 0; i < students.length; i++) { console.log(“Current student:”, students[i]); const chatId = ${students[i].fields["וואטסאפ"]}@c.us; console.log(“Chat ID:”, chatId); // Rest of the code }