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