mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 05:04:05 -08:00
⚡ Small improvements to Zoho CRM Node
This commit is contained in:
parent
977cfbffbe
commit
d207396edf
|
@ -1,4 +1,4 @@
|
||||||
import { INodeProperties } from "n8n-workflow";
|
import { INodeProperties } from 'n8n-workflow';
|
||||||
|
|
||||||
export const leadOperations = [
|
export const leadOperations = [
|
||||||
{
|
{
|
||||||
|
@ -18,6 +18,11 @@ export const leadOperations = [
|
||||||
value: 'create',
|
value: 'create',
|
||||||
description: 'Create a new lead',
|
description: 'Create a new lead',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Delete',
|
||||||
|
value: 'delete',
|
||||||
|
description: 'Delete a lead',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Get',
|
name: 'Get',
|
||||||
value: 'get',
|
value: 'get',
|
||||||
|
@ -38,11 +43,6 @@ export const leadOperations = [
|
||||||
value: 'update',
|
value: 'update',
|
||||||
description: 'Update a lead',
|
description: 'Update a lead',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'Delete',
|
|
||||||
value: 'delete',
|
|
||||||
description: 'Delete a lead',
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
default: 'create',
|
default: 'create',
|
||||||
description: 'The operation to perform.',
|
description: 'The operation to perform.',
|
||||||
|
@ -648,6 +648,15 @@ export const leadFields = [
|
||||||
default: false,
|
default: false,
|
||||||
description: 'To include records from the child territories. True includes child territory records',
|
description: 'To include records from the child territories. True includes child territory records',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Sort By',
|
||||||
|
name: 'sortBy',
|
||||||
|
type: 'multiOptions',
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod: 'getLeadFields',
|
||||||
|
},
|
||||||
|
default: [],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Sort Order',
|
displayName: 'Sort Order',
|
||||||
name: 'sortOrder',
|
name: 'sortOrder',
|
||||||
|
@ -665,15 +674,6 @@ export const leadFields = [
|
||||||
default: 'desc',
|
default: 'desc',
|
||||||
description: 'Order sort attribute ascending or descending.',
|
description: 'Order sort attribute ascending or descending.',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
displayName: 'Sort By',
|
|
||||||
name: 'sortBy',
|
|
||||||
type: 'multiOptions',
|
|
||||||
typeOptions: {
|
|
||||||
loadOptionsMethod: 'getLeadFields',
|
|
||||||
},
|
|
||||||
default: [],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
displayName: 'Territory ID',
|
displayName: 'Territory ID',
|
||||||
name: 'territoryId',
|
name: 'territoryId',
|
||||||
|
|
|
@ -4,11 +4,11 @@ import {
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IDataObject,
|
IDataObject,
|
||||||
INodeExecutionData,
|
|
||||||
INodeTypeDescription,
|
|
||||||
INodeType,
|
|
||||||
ILoadOptionsFunctions,
|
ILoadOptionsFunctions,
|
||||||
|
INodeExecutionData,
|
||||||
INodePropertyOptions,
|
INodePropertyOptions,
|
||||||
|
INodeType,
|
||||||
|
INodeTypeDescription,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -17,13 +17,13 @@ import {
|
||||||
} from './GenericFunctions';
|
} from './GenericFunctions';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
leadOperations,
|
|
||||||
leadFields,
|
leadFields,
|
||||||
|
leadOperations,
|
||||||
} from './LeadDescription';
|
} from './LeadDescription';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ILead,
|
|
||||||
IAddress,
|
IAddress,
|
||||||
|
ILead,
|
||||||
} from './LeadInterface';
|
} from './LeadInterface';
|
||||||
|
|
||||||
export class ZohoCrm implements INodeType {
|
export class ZohoCrm implements INodeType {
|
||||||
|
@ -92,7 +92,7 @@ export class ZohoCrm implements INodeType {
|
||||||
qs.sort_order = 'desc';
|
qs.sort_order = 'desc';
|
||||||
const { data } = await zohoApiRequest.call(this, 'GET', '/accounts', {}, qs);
|
const { data } = await zohoApiRequest.call(this, 'GET', '/accounts', {}, qs);
|
||||||
for (const account of data) {
|
for (const account of data) {
|
||||||
const accountName = account.Account_Name
|
const accountName = account.Account_Name;
|
||||||
const accountId = account.id;
|
const accountId = account.id;
|
||||||
returnData.push({
|
returnData.push({
|
||||||
name: accountName,
|
name: accountName,
|
||||||
|
@ -111,7 +111,7 @@ export class ZohoCrm implements INodeType {
|
||||||
for (const field of fields) {
|
for (const field of fields) {
|
||||||
if (field.api_name === 'Lead_Status') {
|
if (field.api_name === 'Lead_Status') {
|
||||||
for (const value of field.pick_list_values) {
|
for (const value of field.pick_list_values) {
|
||||||
const valueName = value.display_value
|
const valueName = value.display_value;
|
||||||
const valueId = value.actual_value;
|
const valueId = value.actual_value;
|
||||||
returnData.push({
|
returnData.push({
|
||||||
name: valueName,
|
name: valueName,
|
||||||
|
@ -133,7 +133,7 @@ export class ZohoCrm implements INodeType {
|
||||||
for (const field of fields) {
|
for (const field of fields) {
|
||||||
if (field.api_name === 'Lead_Source') {
|
if (field.api_name === 'Lead_Source') {
|
||||||
for (const value of field.pick_list_values) {
|
for (const value of field.pick_list_values) {
|
||||||
const valueName = value.display_value
|
const valueName = value.display_value;
|
||||||
const valueId = value.actual_value;
|
const valueId = value.actual_value;
|
||||||
returnData.push({
|
returnData.push({
|
||||||
name: valueName,
|
name: valueName,
|
||||||
|
@ -155,7 +155,7 @@ export class ZohoCrm implements INodeType {
|
||||||
for (const field of fields) {
|
for (const field of fields) {
|
||||||
if (field.api_name === 'Industry') {
|
if (field.api_name === 'Industry') {
|
||||||
for (const value of field.pick_list_values) {
|
for (const value of field.pick_list_values) {
|
||||||
const valueName = value.display_value
|
const valueName = value.display_value;
|
||||||
const valueId = value.actual_value;
|
const valueId = value.actual_value;
|
||||||
returnData.push({
|
returnData.push({
|
||||||
name: valueName,
|
name: valueName,
|
||||||
|
@ -285,6 +285,10 @@ export class ZohoCrm implements INodeType {
|
||||||
}
|
}
|
||||||
responseData = await zohoApiRequest.call(this, 'POST', '/leads', body);
|
responseData = await zohoApiRequest.call(this, 'POST', '/leads', body);
|
||||||
responseData = responseData.data;
|
responseData = responseData.data;
|
||||||
|
|
||||||
|
if (responseData.length) {
|
||||||
|
responseData = responseData[0].details;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//https://www.zoho.com/crm/developer/docs/api/update-specific-record.html
|
//https://www.zoho.com/crm/developer/docs/api/update-specific-record.html
|
||||||
if (operation === 'update') {
|
if (operation === 'update') {
|
||||||
|
@ -377,12 +381,19 @@ export class ZohoCrm implements INodeType {
|
||||||
}
|
}
|
||||||
responseData = await zohoApiRequest.call(this, 'PUT', `/leads/${leadId}`, body);
|
responseData = await zohoApiRequest.call(this, 'PUT', `/leads/${leadId}`, body);
|
||||||
responseData = responseData.data;
|
responseData = responseData.data;
|
||||||
|
|
||||||
|
if (responseData.length) {
|
||||||
|
responseData = responseData[0].details;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//https://www.zoho.com/crm/developer/docs/api/update-specific-record.html
|
//https://www.zoho.com/crm/developer/docs/api/update-specific-record.html
|
||||||
if (operation === 'get') {
|
if (operation === 'get') {
|
||||||
const leadId = this.getNodeParameter('leadId', i) as string;
|
const leadId = this.getNodeParameter('leadId', i) as string;
|
||||||
responseData = await zohoApiRequest.call(this, 'GET', `/leads/${leadId}`);
|
responseData = await zohoApiRequest.call(this, 'GET', `/leads/${leadId}`);
|
||||||
responseData = responseData.data;
|
if (responseData !== undefined) {
|
||||||
|
responseData = responseData.data;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//https://www.zoho.com/crm/developer/docs/api/get-records.html
|
//https://www.zoho.com/crm/developer/docs/api/get-records.html
|
||||||
if (operation === 'getAll') {
|
if (operation === 'getAll') {
|
||||||
|
|
Loading…
Reference in a new issue