Skip to content

Commit 28c490b

Browse files
committed
updates
1 parent 62b8546 commit 28c490b

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

components/zoho_crm/actions/common/common-objects.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ export default {
173173
] of Object.entries(fields)) {
174174
try {
175175
if (typeof value === "string") {
176-
fields[key] = JSON.parse(value);
176+
fields[key] = typeof JSON.parse(value) === "number"
177+
? value
178+
: JSON.parse(value);
177179
}
178180
} catch {
179181
fields[key] = value;

components/zoho_crm/actions/create-object/create-object.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import common from "../common/common-objects.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
23

34
export default {
45
...common,
@@ -57,8 +58,14 @@ export default {
5758
],
5859
};
5960
const res = await zohoCrm.createObject(moduleType, objectData, $);
60-
if (res.data[0].details.id) {
61+
62+
if (res.data[0].code === "SUCCESS") {
6163
$.export("$summary", `Successfully created new object with ID ${res.data[0].details.id}.`);
64+
} else {
65+
if (res.data[0].code === "INVALID_DATA") {
66+
throw new ConfigurationError(`Error: Invalid data for field '${res.data[0].details.api_name}'. Expected data type: ${res.data[0].details.expected_data_type}`);
67+
}
68+
throw new ConfigurationError(res.data[0].message);
6269
}
6370
return res;
6471
},

components/zoho_crm/actions/update-object/update-object.mjs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import zohoCrm from "../../zoho_crm.app.mjs";
22
import common from "../common/common-objects.mjs";
3+
import { ConfigurationError } from "@pipedream/platform";
34

45
export default {
56
...common,
@@ -58,13 +59,21 @@ export default {
5859
...otherProps,
5960
});
6061

61-
const response = await zohoCrm.updateObject(
62+
const res = await zohoCrm.updateObject(
6263
moduleType,
6364
recordId,
6465
this.parseFields(object),
6566
$,
6667
);
67-
$.export("$summary", `Successfully updated object with ID ${recordId}.`);
68-
return response;
68+
69+
if (res.data[0].code === "SUCCESS") {
70+
$.export("$summary", `Successfully updated object with ID ${recordId}.`);
71+
} else {
72+
if (res.data[0].code === "INVALID_DATA") {
73+
throw new ConfigurationError(`Error: Invalid data for field '${res.data[0].details.api_name}'. Expected data type: ${res.data[0].details.expected_data_type}`);
74+
}
75+
throw new ConfigurationError(res.data[0].message);
76+
}
77+
return res;
6978
},
7079
};

0 commit comments

Comments
 (0)