You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constBATCH_SIZE=10;// The Airtable API allows us to update up to 10 rows per request.
6
7
7
8
exportdefault{
8
9
key: "airtable_oauth-create-multiple-records",
9
10
name: "Create Multiple Records",
10
-
description: "Create one or more records in a table by passing an array of objects containing field names and values as key/value pairs. [See the documentation](https://airtable.com/developers/web/api/create-records)",
11
-
version: "0.0.6",
11
+
description: "Create one or more records in a table in a single operation with an array. [See the documentation](https://airtable.com/developers/web/api/create-records)",
12
+
version: "0.1.{{ts}}",
12
13
type: "action",
13
14
props: {
14
15
...common.props,
@@ -18,6 +19,15 @@ export default {
18
19
"records",
19
20
],
20
21
},
22
+
customExpressionInfo: {
23
+
type: "alert",
24
+
alertType: "info",
25
+
content: `You can use a custom expression that evaluates to an object for each entry in the array, e.g. \`{{ { "foo": "bar", "id": 123 } }}\`.
26
+
\\
27
+
You can also reference an object exported by a previous step, e.g. \`{{steps.foo.$return_value}}\`.
28
+
\\
29
+
If desired, you can use a custom expression in the same fashion for the entire array instead of providing individual values.`,
30
+
},
21
31
typecast: {
22
32
propDefinition: [
23
33
airtable,
@@ -39,9 +49,18 @@ export default {
39
49
if(!Array.isArray(data)){
40
50
data=JSON.parse(data);
41
51
}
42
-
data=data.map((fields)=>({
43
-
fields,
44
-
}));
52
+
data=data.map((fields,index)=>{
53
+
if(typeoffields==="string"){
54
+
try{
55
+
fields=JSON.parse(fields);
56
+
}catch(err){
57
+
thrownewConfigurationError(`Error parsing record (index ${index}) as JSON: ${err.message}`);
58
+
}
59
+
}
60
+
return{
61
+
fields,
62
+
};
63
+
});
45
64
if(!data.length){
46
65
thrownewError("No Airtable record data passed to step. Please pass at least one record");
Copy file name to clipboardExpand all lines: components/airtable_oauth/airtable_oauth.app.mjs
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -205,9 +205,9 @@ export default {
205
205
optional: true,
206
206
},
207
207
records: {
208
-
type: "string",
208
+
type: "string[]",
209
209
label: "Records",
210
-
description: "Provide an array of objects. Each object should represent a new record with the column name as the key and the data to insert as the corresponding value (e.g., passing `[{\"foo\":\"bar\",\"id\":123},{\"foo\":\"baz\",\"id\":456}]` will create two records and with values added to the fields `foo` and `id`). The most common pattern is to reference an array of objects exported by a previous step (e.g., `{{steps.foo.$return_value}}`). You may also enter or construct a string that will `JSON.parse()` to an array of objects.",
210
+
description: "Each item in the array should be an object in JSON format, representing a new record. The keys are the column names and the corresponding values are the data to insert.",
211
211
},
212
212
typecast: {
213
213
type: "boolean",
@@ -224,7 +224,7 @@ export default {
224
224
type: "alert",
225
225
alertType: "info",
226
226
content: `A custom expression can be a JSON object with key/value pairs representing columns and values, e.g. \`{{ { "foo": "bar", "id": 123 } }}\`.
227
-
\\\\
227
+
\\
228
228
You can also reference an object exported by a previous step, e.g. \`{{steps.foo.$return_value}}\`.`,
0 commit comments