Skip to content

Commit be042cb

Browse files
committed
allow picklist fields
1 parent 9b99998 commit be042cb

File tree

4 files changed

+48
-12
lines changed

4 files changed

+48
-12
lines changed

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

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,33 @@ export default {
2828
&& !field.system_mandatory
2929
&& field.operation_type[`api_${type}`]
3030
&& ![
31-
"picklist",
3231
"lookup",
3332
"ownerlookup",
3433
"profileimage",
3534
].includes(field.data_type));
3635
},
37-
getType(dataType) {
36+
getType({
37+
data_type: dataType, json_type: jsonType,
38+
}) {
39+
let type;
3840
switch (dataType) {
3941
case "boolean":
40-
return "boolean";
42+
type = "boolean";
43+
break;
4144
case "integer":
42-
return "integer";
45+
type = "integer";
46+
break;
4347
case "bigint":
44-
return "integer";
48+
type = "integer";
49+
break;
4550
default:
46-
return "string";
51+
type = "string";
52+
break;
53+
};
54+
if (jsonType === "jsonarray") {
55+
return `${type}[]`;
4756
}
57+
return type;
4858
},
4959
getRequiredProps(moduleType, type = "create") {
5060
let props = {};
@@ -142,8 +152,34 @@ export default {
142152
label: field.display_label,
143153
optional: true,
144154
};
155+
if (field.pick_list_values?.length) {
156+
props[field.api_name].options = field.pick_list_values.map(({
157+
display_value: label, actual_value: value,
158+
}) => ({
159+
value,
160+
label,
161+
}));
162+
}
145163
}
146164
return props;
147165
},
166+
parseFields(fields) {
167+
if (!fields) {
168+
return;
169+
}
170+
for (const [
171+
key,
172+
value,
173+
] of Object.entries(fields)) {
174+
try {
175+
if (typeof value === "string") {
176+
fields[key] = JSON.parse(value);
177+
}
178+
} catch {
179+
fields[key] = value;
180+
}
181+
}
182+
return fields;
183+
},
148184
},
149185
};

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "zoho_crm-create-object",
66
name: "Create Object",
77
description: "Create a new object/module entry. [See the documentation](https://www.zoho.com/crm/developer/docs/api/v2/insert-records.html)",
8-
version: "0.3.2",
8+
version: "0.3.3",
99
type: "action",
1010
async additionalProps() {
1111
const requiredProps = this.getRequiredProps(this.moduleType);
@@ -53,7 +53,7 @@ export default {
5353
});
5454
const objectData = {
5555
data: [
56-
object,
56+
this.parseFields(object),
5757
],
5858
};
5959
const res = await zohoCrm.createObject(moduleType, objectData, $);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "zoho_crm-update-object",
77
name: "Update Object",
88
description: "Updates existing entities in the module. [See the documentation](https://www.zoho.com/crm/developer/docs/api/v2/update-records.html)",
9-
version: "0.3.2",
9+
version: "0.3.3",
1010
type: "action",
1111
props: {
1212
...common.props,
@@ -61,7 +61,7 @@ export default {
6161
const response = await zohoCrm.updateObject(
6262
moduleType,
6363
recordId,
64-
object,
64+
this.parseFields(object),
6565
$,
6666
);
6767
$.export("$summary", `Successfully updated object with ID ${recordId}.`);

components/zoho_crm/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/zoho_crm",
3-
"version": "0.5.2",
3+
"version": "0.5.3",
44
"description": "Pipedream Zoho CRM Components",
55
"main": "zoho_crm.app.mjs",
66
"keywords": [
@@ -10,7 +10,7 @@
1010
"homepage": "https://pipedream.com/apps/zoho_crm",
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"dependencies": {
13-
"@pipedream/platform": "^1.2.0",
13+
"@pipedream/platform": "^3.0.3",
1414
"crypto": "^1.0.1",
1515
"lodash.sortby": "^4.7.0"
1616
},

0 commit comments

Comments
 (0)