I apologize for the confusion and any frustration this may have caused. It seems there might be an issue with the import statement or the environment. Let’s try a different approach. Instead of using the @pipedream/platform
package, we can use the built-in axios
package. Please update the import statement and try the following code: import axios from "axios"; export default defineComponent({ props: { apiKey: { type: "string", label: "API Key", default: "YOUR_SEATABLE_API_KEY", }, baseId: { type: "string", label: "Base ID", default: "YOUR_BASE_ID", }, tableName: { type: "string", label: "Table Name", }, formula: { type: "string", label: "Filter Formula", }, }, async run({ $ }) { const apiURL = `https://cloud.seatable.io/dtable-server/api/v1/dtables/${this.baseId}/rows/`; const headers = { "Content-Type": "application/json", Authorization: `Token ${this.apiKey}`, }; try { const response = await axios({ method: "GET", url: apiURL, headers: headers, params: { table_name: this.tableName, }, }); if (!response.data || !response.data.rows) { console.log("Response data or rows property is missing:", response); return; } // Apply your filter formula here const filteredRows = response.data.rows.filter(row => { // Evaluate the formula logic return eval(this.formula); }); return filteredRows; } catch (error) { console.error("Error while fetching data:", error); } }, });
This code uses the built-in axios
package instead of the @pipedream/platform
package. Please try this updated code and let me know if you need further assistance.
OK I’m checkin. In the meantime can you tell me why there is no “copy” buttom in the side of your code?
I apologize for any inconvenience caused by the lack of a “copy” button for the code I provided. As a text-based AI, I’m unable to provide a copy button directly within my responses. However, you can manually copy the code by selecting it with your cursor and using your system’s copy functionality (e.g., Ctrl+C or Cmd+C). If you have any further questions or need assistance, please let me know.
but in ChatGPT 3.5 there is a copy buttom…
I apologize for the confusion. As an AI, I don’t have direct control over the UI features of ChatGPT 3.5 or other platforms. My main function is to provide assistance and answer questions related to Pipedream. If you have any further questions or need help with Pipedream, please feel free to ask.
OK, the code worked! now let’s go to next step. I want to use a hebrew table name (like “לומדים”), hebrew colums in the formula (like “שם”) and Hebrew value (“דוד” insted of “JON”) .
Can you add encoding functions in the code and explain how to put it in the props as well? (is it in the configuration section or in the code? )
I’m glad the code worked! To use Hebrew values in the table name, columns, and formula, you don’t need any special encoding functions. You can simply replace the English values with the Hebrew values directly in the props and the code. Here’s the updated code with Hebrew values: import axios from "axios"; export default defineComponent({ props: { apiKey: { type: "string", label: "API Key", default: "YOUR_SEATABLE_API_KEY", }, baseId: { type: "string", label: "Base ID", default: "YOUR_BASE_ID", }, tableName: { type: "string", label: "Table Name", default: "לומדים", }, formula: { type: "string", label: "Filter Formula", default: 'שם === "דוד"', }, }, async run({ $ }) { const apiURL = `https://cloud.seatable.io/dtable-server/api/v1/dtables/${this.baseId}/rows/`; const headers = { "Content-Type": "application/json", Authorization: `Token ${this.apiKey}`, }; try { const response = await axios({ method: "GET", url: apiURL, headers: headers, params: { table_name: this.tableName, }, }); if (!response.data || !response.data.rows) { console.log("Response data or rows property is missing:", response); return; } // Apply your filter formula here const filteredRows = response.data.rows.filter(row => { // Evaluate the formula logic return eval(this.formula); }); return filteredRows; } catch (error) { console.error("Error while fetching data:", error); } }, });
In this example, I’ve set the default values for tableName
and formula
to Hebrew values. You can adjust these values as needed. When you add this code as a step in your Pipedream workflow, you’ll see the props with their default Hebrew values in the configuration section. You can modify them directly in the UI if needed.
amazing! Now I put this formula:
תאריך עברי === “כ״ג סיון”
as I have colum named תאריך עברי and the value I’m searching is כ"ג סיון and I got in the log Error while fetching data: [SyntaxError: Unexpected identifier]
What’s wrong?
I apologize for the confusion. The issue is likely due to the use of special characters in the formula string. To resolve this, you can use template literals with backticks (`
) instead of single or double quotes for the formula string. Here’s the updated code: ```
export default defineComponent({ props: { // … formula: { type: “string”, label: “Filter Formula”, default: תאריך עברי === "כ״ג סיון"
, }, }, async run({ $ }) { // … }, });
still not working. I think we have to put {} on the colum name. Don’t you?
You’re right, my apologies for the oversight. To use variables in the formula string, you need to use template literals with backticks and wrap the column name with curly braces (${}
). Here’s the updated code: export default defineComponent({ props: { // ... formula: { type: "string", label: "Filter Formula", default: `תאריך_עברי === "כ״ג סיון"`, }, }, async run({ $ }) { // ... // Apply your filter formula here const filteredRows = response.data.rows.filter(row => { // Evaluate the formula logic return eval(this.formula.replace("תאריך_עברי", `"${row['תאריך עברי']}"`)); }); return filteredRows; }, });
In this example, I’ve replaced the column name with a placeholder (תאריך_עברי
) in the default formula string. Then, within the filter
function, I replace the placeholder with the actual value of the column from the row data, wrapped in double quotes and curly braces. This should resolve the issue with the formula evaluation.
OK another step!
I have this formula that’s working great:
row.NAME && row.NAME.includes(“JON”);
now if the colum name is 2 words or more (like FIRST NAME), I get error. can you help?
I understand the issue you’re facing. When dealing with column names that have spaces, you should use bracket notation to access the property. Here’s the updated formula: ```
row[“FIRST NAME”] && row[“FIRST NAME”].includes(“JON”);
YEHHHH great.
Now last step (I hope…)
let’s say I have " in the value I’m filttering (like D"R JON) . How can we filter it?
I understand that you want to filter a value containing double quotes, like D"R JON
. To handle this, you can use escape characters to include the double quotes in your filter condition. Here’s an example: row["FIRST NAME"] && row["FIRST NAME"].includes('D"R JON');
In this example, I’ve used single quotes ('
) to wrap the string containing the double quotes ("
). This way, the double quotes are treated as part of the string and not as a delimiter.
in other code I have this row:
I see that you mentioned a row in your code, but you didn’t provide the actual code or context. Can you please provide more information or share the code snippet you’re referring to? This will help me understand the issue and provide a more accurate solution.
in other code I have this row:
const apiUrl = ‘https://api.green-api.com/waInstance1101796351/SendMessage/af6a35aea200435aa8c83d09acd9f5e117cf832eb15d4b2094/’;
I want to replave 1101796351 in this.instance and /af6a35aea200435aa8c83d09acd9f5e117cf832eb15d4b2094/
in this.token
How can I do that?
Ofcourse I have props
To replace the instance and token values in the apiUrl
with the respective props, you can use template literals with backticks. Here’s an example: export default defineComponent({ props: { instance: { type: "string", label: "Instance", }, token: { type: "string", label: "Token", }, }, async run({ $ }) { const apiUrl = `https://api.green-api.com/waInstance${this.instance}/SendMessage/${this.token}/`; // ... rest of your code }, });
In this example, I’ve used ${this.instance}
and ${this.token}
within the template literal to replace the respective values in the apiUrl
. Make sure to update the rest of your code accordingly.
great job! if I want to filter in the formula instead of “includes” > is