Browse Source

fix: error when insert `array` type column in google sheets

Ahmad Kholid 3 years ago
parent
commit
4b248a38af

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "automa",
-  "version": "1.9.4-beta",
+  "version": "1.9.5",
   "description": "An extension for automating your browser by connecting blocks",
   "license": "MIT",
   "repository": {

+ 5 - 1
src/background/workflowEngine/blocksHandler/handlerGoogleSheets.js

@@ -38,7 +38,11 @@ async function updateSpreadsheetValues(
     if (keysAsFirstRow) {
       values = convertArrObjTo2DArr(columns);
     } else {
-      values = columns.map(Object.values);
+      values = columns.map((item) =>
+        Object.values(item).map((value) =>
+          typeof value === 'object' ? JSON.stringify(value) : value
+        )
+      );
     }
   } else if (dataFrom === 'custom') {
     values = parseJSON(customData, customData);

+ 3 - 1
src/utils/helper.js

@@ -55,8 +55,10 @@ export function convertArrObjTo2DArr(arr) {
         values[0].push(key);
       }
 
+      const value = obj[key];
+
       const rowIndex = keyIndex.get(key);
-      row[rowIndex] = obj[key];
+      row[rowIndex] = typeof value === 'object' ? JSON.stringify(value) : value;
     });
 
     values.push([...row]);