# nodes

node_type: n8n-nodes-base.Salesforce
name: Salesforce
display_name: Salesforce
description: Consume Salesforce API
category: output
icon: file:salesforce.svg
code_hash: 6f246b98c15db36cd6ecfb303d5edf8861482d616bc7a416a74aa341105120c3
documentation_url: https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.salesforcetrigger
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 09:18:26
updated_at: 2025-06-08 09:18:26
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Salesforce = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const AccountDescription_1 = require("./AccountDescription");
  const AttachmentDescription_1 = require("./AttachmentDescription");
  const CaseDescription_1 = require("./CaseDescription");
  const ContactDescription_1 = require("./ContactDescription");
  const CustomObjectDescription_1 = require("./CustomObjectDescription");
  const FlowDescription_1 = require("./FlowDescription");
  const GenericFunctions_1 = require("./GenericFunctions");
  const LeadDescription_1 = require("./LeadDescription");
  const OpportunityDescription_1 = require("./OpportunityDescription");
  const SearchDescription_1 = require("./SearchDescription");
  const TaskDescription_1 = require("./TaskDescription");
  const UserDescription_1 = require("./UserDescription");
  const DocumentDescription_1 = require("./DocumentDescription");
  class Salesforce {
      constructor() {
          this.description = {
              displayName: 'Salesforce',
              name: 'salesforce',
              icon: 'file:salesforce.svg',
              group: ['output'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume Salesforce API',
              defaults: {
                  name: 'Salesforce',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'salesforceOAuth2Api',
                      required: true,
                      displayOptions: {
                          show: {
                              authentication: ['oAuth2'],
                          },
                      },
                  },
                  {
                      name: 'salesforceJwtApi',
                      required: true,
                      displayOptions: {
                          show: {
                              authentication: ['jwt'],
                          },
                      },
                  },
              ],
              properties: [
                  {
                      displayName: 'Authentication',
                      name: 'authentication',
                      type: 'options',
                      options: [
                          {
                              name: 'OAuth2',
                              value: 'oAuth2',
                          },
                          {
                              name: 'OAuth2 JWT',
                              value: 'jwt',
                          },
                      ],
                      default: 'oAuth2',
                      description: 'OAuth Authorization Flow',
                  },
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Account',
                              value: 'account',
                              description: 'Represents an individual account, which is an organization or person involved with your business (such as customers, competitors, and partners)',
                          },
                          {
                              name: 'Attachment',
                              value: 'attachment',
                              description: 'Represents a file that a has uploaded and attached to a parent object',
                          },
                          {
                              name: 'Case',
                              value: 'case',
                              description: 'Represents a case, which is a customer issue or problem',
                          },
                          {
                              name: 'Contact',
                              value: 'contact',
                              description: 'Represents a contact, which is an individual associated with an account',
                          },
                          {
                              name: 'Custom Object',
                              value: 'customObject',
                              description: 'Represents a custom object',
                          },
                          {
                              name: 'Document',
                              value: 'document',
                              description: 'Represents a document',
                          },
                          {
                              name: 'Flow',
                              value: 'flow',
                              description: 'Represents an autolaunched flow',
                          },
                          {
                              name: 'Lead',
                              value: 'lead',
                              description: 'Represents a prospect or potential',
                          },
                          {
                              name: 'Opportunity',
                              value: 'opportunity',
                              description: 'Represents an opportunity, which is a sale or pending deal',
                          },
                          {
                              name: 'Search',
                              value: 'search',
                              description: 'Search records',
                          },
                          {
                              name: 'Task',
                              value: 'task',
                              description: 'Represents a business activity such as making a phone call or other to-do items. In the user interface, and records are collectively referred to as activities.',
                          },
                          {
                              name: 'User',
                              value: 'user',
                              description: 'Represents a person, which is one user in system',
                          },
                      ],
                      default: 'lead',
                  },
                  ...LeadDescription_1.leadOperations,
                  ...LeadDescription_1.leadFields,
                  ...ContactDescription_1.contactOperations,
                  ...ContactDescription_1.contactFields,
                  ...CustomObjectDescription_1.customObjectOperations,
                  ...CustomObjectDescription_1.customObjectFields,
                  ...DocumentDescription_1.documentOperations,
                  ...DocumentDescription_1.documentFields,
                  ...OpportunityDescription_1.opportunityOperations,
                  ...OpportunityDescription_1.opportunityFields,
                  ...AccountDescription_1.accountOperations,
                  ...AccountDescription_1.accountFields,
                  ...SearchDescription_1.searchOperations,
                  ...SearchDescription_1.searchFields,
                  ...CaseDescription_1.caseOperations,
                  ...CaseDescription_1.caseFields,
                  ...TaskDescription_1.taskOperations,
                  ...TaskDescription_1.taskFields,
                  ...AttachmentDescription_1.attachmentOperations,
                  ...AttachmentDescription_1.attachmentFields,
                  ...UserDescription_1.userOperations,
                  ...UserDescription_1.userFields,
                  ...FlowDescription_1.flowOperations,
                  ...FlowDescription_1.flowFields,
              ],
          };
          this.methods = {
              loadOptions: {
                  async getLeadStatuses() {
                      const returnData = [];
                      const qs = {
                          q: 'SELECT id, MasterLabel FROM LeadStatus',
                      };
                      const statuses = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                      for (const status of statuses) {
                          const statusName = status.MasterLabel;
                          returnData.push({
                              name: statusName,
                              value: statusName,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getUsers() {
                      const returnData = [];
                      const qs = {
                          q: 'SELECT id, Name FROM User',
                      };
                      const users = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                      for (const user of users) {
                          const userName = user.Name;
                          const userId = user.Id;
                          returnData.push({
                              name: userName,
                              value: userId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCaseOwners() {
                      const returnData = [];
                      const qsQueues = {
                          q: "SELECT Queue.Id, Queue.Name FROM QueuesObject where Queue.Type='Queue' and SobjectType = 'Case'",
                      };
                      const queues = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qsQueues);
                      for (const queue of queues) {
                          const queueName = queue.Queue.Name;
                          const queueId = queue.Queue.Id;
                          returnData.push({
                              name: `Queue: ${queueName}`,
                              value: queueId,
                          });
                      }
                      const qsUsers = {
                          q: 'SELECT id, Name FROM User',
                      };
                      const users = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qsUsers);
                      const userPrefix = returnData.length > 0 ? 'User: ' : '';
                      for (const user of users) {
                          const userName = user.Name;
                          const userId = user.Id;
                          returnData.push({
                              name: userPrefix + userName,
                              value: userId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getLeadOwners() {
                      const returnData = [];
                      const qsQueues = {
                          q: "SELECT Queue.Id, Queue.Name FROM QueuesObject where Queue.Type='Queue' and SobjectType = 'Lead'",
                      };
                      const queues = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qsQueues);
                      for (const queue of queues) {
                          const queueName = queue.Queue.Name;
                          const queueId = queue.Queue.Id;
                          returnData.push({
                              name: `Queue: ${queueName}`,
                              value: queueId,
                          });
                      }
                      const qsUsers = {
                          q: 'SELECT id, Name FROM User',
                      };
                      const users = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qsUsers);
                      const userPrefix = returnData.length > 0 ? 'User: ' : '';
                      for (const user of users) {
                          const userName = user.Name;
                          const userId = user.Id;
                          returnData.push({
                              name: userPrefix + userName,
                              value: userId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getLeadSources() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/lead/describe');
                      for (const field of fields) {
                          if (field.name === 'LeadSource') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCustomFields() {
                      const returnData = [];
                      const resource = this.getNodeParameter('resource', 0);
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/${resource}/describe`);
                      for (const field of fields) {
                          if (field.custom === true) {
                              const fieldName = field.label;
                              const fieldId = field.name;
                              returnData.push({
                                  name: fieldName,
                                  value: fieldId,
                              });
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getRecordTypes() {
                      const returnData = [];
                      let resource = this.getNodeParameter('resource', 0);
                      if (resource === 'customObject') {
                          resource = this.getNodeParameter('customObject', 0);
                      }
                      const qs = {
                          q: `SELECT Id, Name, SobjectType, IsActive FROM RecordType WHERE SobjectType = '${resource}'`,
                      };
                      const types = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                      for (const type of types) {
                          if (type.IsActive === true) {
                              returnData.push({
                                  name: type.Name,
                                  value: type.Id,
                              });
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getExternalIdFields() {
                      const returnData = [];
                      let resource = this.getCurrentNodeParameter('resource');
                      resource =
                          resource === 'customObject'
                              ? this.getCurrentNodeParameter('customObject')
                              : resource;
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/${resource}/describe`);
                      for (const field of fields) {
                          if (field.externalId === true || field.idLookup === true) {
                              const fieldName = field.label;
                              const fieldId = field.name;
                              returnData.push({
                                  name: fieldName,
                                  value: fieldId,
                              });
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getAccounts() {
                      const returnData = [];
                      const qs = {
                          q: 'SELECT id, Name FROM Account',
                      };
                      const accounts = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                      for (const account of accounts) {
                          const accountName = account.Name;
                          const accountId = account.Id;
                          returnData.push({
                              name: accountName,
                              value: accountId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCampaigns() {
                      const returnData = [];
                      const qs = {
                          q: 'SELECT id, Name FROM Campaign',
                      };
                      const campaigns = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                      for (const campaign of campaigns) {
                          const campaignName = campaign.Name;
                          const campaignId = campaign.Id;
                          returnData.push({
                              name: campaignName,
                              value: campaignId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getStages() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/opportunity/describe');
                      for (const field of fields) {
                          if (field.name === 'StageName') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getAccountTypes() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/account/describe');
                      for (const field of fields) {
                          if (field.name === 'Type') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getAccountSources() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/account/describe');
                      for (const field of fields) {
                          if (field.name === 'AccountSource') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCaseTypes() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/case/describe');
                      for (const field of fields) {
                          if (field.name === 'Type') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCaseStatuses() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/case/describe');
                      for (const field of fields) {
                          if (field.name === 'Status') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCaseReasons() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/case/describe');
                      for (const field of fields) {
                          if (field.name === 'Reason') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCaseOrigins() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/case/describe');
                      for (const field of fields) {
                          if (field.name === 'Origin') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCasePriorities() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/case/describe');
                      for (const field of fields) {
                          if (field.name === 'Priority') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getTaskStatuses() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/task/describe');
                      for (const field of fields) {
                          if (field.name === 'Status') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getTaskTypes() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/task/describe');
                      for (const field of fields) {
                          if (field.name === 'TaskSubtype') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getTaskSubjects() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/task/describe');
                      for (const field of fields) {
                          if (field.name === 'Subject') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getTaskCallTypes() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/task/describe');
                      for (const field of fields) {
                          if (field.name === 'CallType') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getTaskPriorities() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/task/describe');
                      for (const field of fields) {
                          if (field.name === 'Priority') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getTaskRecurrenceTypes() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/task/describe');
                      for (const field of fields) {
                          if (field.name === 'RecurrenceType') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getTaskRecurrenceInstances() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/task/describe');
                      for (const field of fields) {
                          if (field.name === 'RecurrenceInstance') {
                              for (const pickValue of field.picklistValues) {
                                  const pickValueName = pickValue.label;
                                  const pickValueId = pickValue.value;
                                  returnData.push({
                                      name: pickValueName,
                                      value: pickValueId,
                                  });
                              }
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCustomObjects() {
                      const returnData = [];
                      const { sobjects: objects } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects');
                      for (const object of objects) {
                          if (object.custom === true) {
                              const objectName = object.label;
                              const objectId = object.name;
                              returnData.push({
                                  name: objectName,
                                  value: objectId,
                              });
                          }
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCustomObjectFields() {
                      const returnData = [];
                      const customObject = this.getCurrentNodeParameter('customObject');
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/${customObject}/describe`);
                      for (const field of fields) {
                          const fieldName = field.label;
                          const fieldId = field.name;
                          returnData.push({
                              name: fieldName,
                              value: fieldId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getAccountFields() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/account/describe');
                      for (const field of fields) {
                          const fieldName = field.label;
                          const fieldId = field.name;
                          returnData.push({
                              name: fieldName,
                              value: fieldId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getAtachmentFields() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/attachment/describe');
                      for (const field of fields) {
                          const fieldName = field.label;
                          const fieldId = field.name;
                          returnData.push({
                              name: fieldName,
                              value: fieldId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getCaseFields() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/case/describe');
                      for (const field of fields) {
                          const fieldName = field.label;
                          const fieldId = field.name;
                          returnData.push({
                              name: fieldName,
                              value: fieldId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getLeadFields() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/lead/describe');
                      for (const field of fields) {
                          const fieldName = field.label;
                          const fieldId = field.name;
                          returnData.push({
                              name: fieldName,
                              value: fieldId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getOpportunityFields() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/opportunity/describe');
                      for (const field of fields) {
                          const fieldName = field.label;
                          const fieldId = field.name;
                          returnData.push({
                              name: fieldName,
                              value: fieldId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getTaskFields() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/task/describe');
                      for (const field of fields) {
                          const fieldName = field.label;
                          const fieldId = field.name;
                          returnData.push({
                              name: fieldName,
                              value: fieldId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getUserFields() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/user/describe');
                      for (const field of fields) {
                          const fieldName = field.label;
                          const fieldId = field.name;
                          returnData.push({
                              name: fieldName,
                              value: fieldId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
                  async getContactFields() {
                      const returnData = [];
                      const { fields } = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/contact/describe');
                      for (const field of fields) {
                          const fieldName = field.label;
                          const fieldId = field.name;
                          returnData.push({
                              name: fieldName,
                              value: fieldId,
                          });
                      }
                      (0, GenericFunctions_1.sortOptions)(returnData);
                      return returnData;
                  },
              },
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          let responseData;
          const qs = {};
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          this.logger.debug(`Running "Salesforce" node named "${this.getNode.name}" resource "${resource}" operation "${operation}"`);
          for (let i = 0; i < items.length; i++) {
              try {
                  if (resource === 'lead') {
                      if (operation === 'create' || operation === 'upsert') {
                          const company = this.getNodeParameter('company', i);
                          const lastname = this.getNodeParameter('lastname', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const body = {
                              Company: company,
                              LastName: lastname,
                          };
                          if (additionalFields.hasOptedOutOfEmail !== undefined) {
                              body.HasOptedOutOfEmail = additionalFields.hasOptedOutOfEmail;
                          }
                          if (additionalFields.hasOptedOutOfFax !== undefined) {
                              body.HasOptedOutOfFax = additionalFields.hasOptedOutOfFax;
                          }
                          if (additionalFields.email !== undefined) {
                              body.Email = additionalFields.email;
                          }
                          if (additionalFields.city !== undefined) {
                              body.City = additionalFields.city;
                          }
                          if (additionalFields.phone !== undefined) {
                              body.Phone = additionalFields.phone;
                          }
                          if (additionalFields.state !== undefined) {
                              body.State = additionalFields.state;
                          }
                          if (additionalFields.title !== undefined) {
                              body.Title = additionalFields.title;
                          }
                          if (additionalFields.jigsaw !== undefined) {
                              body.Jigsaw = additionalFields.jigsaw;
                          }
                          if (additionalFields.rating !== undefined) {
                              body.Rating = additionalFields.rating;
                          }
                          if (additionalFields.status !== undefined) {
                              body.Status = additionalFields.status;
                          }
                          if (additionalFields.street !== undefined) {
                              body.Street = additionalFields.street;
                          }
                          if (additionalFields.country !== undefined) {
                              body.Country = additionalFields.country;
                          }
                          if (additionalFields.owner !== undefined) {
                              body.OwnerId = additionalFields.owner;
                          }
                          if (additionalFields.website !== undefined) {
                              body.Website = additionalFields.website;
                          }
                          if (additionalFields.industry !== undefined) {
                              body.Industry = additionalFields.industry;
                          }
                          if (additionalFields.fax !== undefined) {
                              body.Fax = additionalFields.fax;
                          }
                          if (additionalFields.firstname !== undefined) {
                              body.FirstName = additionalFields.firstname;
                          }
                          if (additionalFields.leadSource !== undefined) {
                              body.LeadSource = additionalFields.leadSource;
                          }
                          if (additionalFields.postalCode !== undefined) {
                              body.PostalCode = additionalFields.postalCode;
                          }
                          if (additionalFields.salutation !== undefined) {
                              body.Salutation = additionalFields.salutation;
                          }
                          if (additionalFields.description !== undefined) {
                              body.Description = additionalFields.description;
                          }
                          if (additionalFields.annualRevenue !== undefined) {
                              body.AnnualRevenue = additionalFields.annualRevenue;
                          }
                          if (additionalFields.isUnreadByOwner !== undefined) {
                              body.IsUnreadByOwner = additionalFields.isUnreadByOwner;
                          }
                          if (additionalFields.numberOfEmployees !== undefined) {
                              body.NumberOfEmployees = additionalFields.numberOfEmployees;
                          }
                          if (additionalFields.mobilePhone !== undefined) {
                              body.MobilePhone = additionalFields.mobilePhone;
                          }
                          if (additionalFields.recordTypeId !== undefined) {
                              body.RecordTypeId = additionalFields.recordTypeId;
                          }
                          if (additionalFields.customFieldsUi) {
                              const customFields = additionalFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          let endpoint = '/sobjects/lead';
                          let method = 'POST';
                          if (operation === 'upsert') {
                              method = 'PATCH';
                              const externalId = this.getNodeParameter('externalId', 0);
                              const externalIdValue = this.getNodeParameter('externalIdValue', i);
                              endpoint = `/sobjects/lead/${externalId}/${externalIdValue}`;
                              if (body[externalId] !== undefined) {
                                  delete body[externalId];
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, method, endpoint, body);
                      }
                      if (operation === 'update') {
                          const leadId = this.getNodeParameter('leadId', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {};
                          if (!Object.keys(updateFields).length) {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'You must add at least one update field', { itemIndex: i });
                          }
                          if (updateFields.hasOptedOutOfEmail !== undefined) {
                              body.HasOptedOutOfEmail = updateFields.hasOptedOutOfEmail;
                          }
                          if (updateFields.hasOptedOutOfFax !== undefined) {
                              body.hasOptedOutOfFax = updateFields.hasOptedOutOfFax;
                          }
                          if (updateFields.lastname !== undefined) {
                              body.LastName = updateFields.lastname;
                          }
                          if (updateFields.company !== undefined) {
                              body.Company = updateFields.company;
                          }
                          if (updateFields.email !== undefined) {
                              body.Email = updateFields.email;
                          }
                          if (updateFields.city !== undefined) {
                              body.City = updateFields.city;
                          }
                          if (updateFields.phone !== undefined) {
                              body.Phone = updateFields.phone;
                          }
                          if (updateFields.state !== undefined) {
                              body.State = updateFields.state;
                          }
                          if (updateFields.title !== undefined) {
                              body.Title = updateFields.title;
                          }
                          if (updateFields.jigsaw !== undefined) {
                              body.Jigsaw = updateFields.jigsaw;
                          }
                          if (updateFields.rating !== undefined) {
                              body.Rating = updateFields.rating;
                          }
                          if (updateFields.status !== undefined) {
                              body.Status = updateFields.status;
                          }
                          if (updateFields.street !== undefined) {
                              body.Street = updateFields.street;
                          }
                          if (updateFields.country !== undefined) {
                              body.Country = updateFields.country;
                          }
                          if (updateFields.owner !== undefined) {
                              body.OwnerId = updateFields.owner;
                          }
                          if (updateFields.website !== undefined) {
                              body.Website = updateFields.website;
                          }
                          if (updateFields.industry !== undefined) {
                              body.Industry = updateFields.industry;
                          }
                          if (updateFields.firstname !== undefined) {
                              body.FirstName = updateFields.firstname;
                          }
                          if (updateFields.fax !== undefined) {
                              body.Fax = updateFields.fax;
                          }
                          if (updateFields.leadSource !== undefined) {
                              body.LeadSource = updateFields.leadSource;
                          }
                          if (updateFields.postalCode !== undefined) {
                              body.PostalCode = updateFields.postalCode;
                          }
                          if (updateFields.salutation !== undefined) {
                              body.Salutation = updateFields.salutation;
                          }
                          if (updateFields.description !== undefined) {
                              body.Description = updateFields.description;
                          }
                          if (updateFields.annualRevenue !== undefined) {
                              body.AnnualRevenue = updateFields.annualRevenue;
                          }
                          if (updateFields.isUnreadByOwner !== undefined) {
                              body.IsUnreadByOwner = updateFields.isUnreadByOwner;
                          }
                          if (updateFields.numberOfEmployees !== undefined) {
                              body.NumberOfEmployees = updateFields.numberOfEmployees;
                          }
                          if (updateFields.mobilePhone !== undefined) {
                              body.MobilePhone = updateFields.mobilePhone;
                          }
                          if (updateFields.recordTypeId !== undefined) {
                              body.RecordTypeId = updateFields.recordTypeId;
                          }
                          if (updateFields.customFieldsUi) {
                              const customFields = updateFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'PATCH', `/sobjects/lead/${leadId}`, body);
                      }
                      if (operation === 'get') {
                          const leadId = this.getNodeParameter('leadId', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/lead/${leadId}`);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          try {
                              if (returnAll) {
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Lead', returnAll);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                              else {
                                  const limit = this.getNodeParameter('limit', i);
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Lead', returnAll, limit);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'delete') {
                          const leadId = this.getNodeParameter('leadId', i);
                          try {
                              responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'DELETE', `/sobjects/lead/${leadId}`);
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'getSummary') {
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/lead');
                      }
                      if (operation === 'addToCampaign') {
                          const leadId = this.getNodeParameter('leadId', i);
                          const campaignId = this.getNodeParameter('campaignId', i);
                          const options = this.getNodeParameter('options', i);
                          const body = {
                              LeadId: leadId,
                              CampaignId: campaignId,
                          };
                          if (options.status) {
                              body.Status = options.status;
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/CampaignMember', body);
                      }
                      if (operation === 'addNote') {
                          const leadId = this.getNodeParameter('leadId', i);
                          const title = this.getNodeParameter('title', i);
                          const options = this.getNodeParameter('options', i);
                          const body = {
                              Title: title,
                              ParentId: leadId,
                          };
                          if (options.body) {
                              body.Body = options.body;
                          }
                          if (options.owner) {
                              body.OwnerId = options.owner;
                          }
                          if (options.isPrivate) {
                              body.IsPrivate = options.isPrivate;
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/note', body);
                      }
                  }
                  if (resource === 'contact') {
                      if (operation === 'create' || operation === 'upsert') {
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const lastname = this.getNodeParameter('lastname', i);
                          const body = {
                              LastName: lastname,
                          };
                          if (additionalFields.fax !== undefined) {
                              body.Fax = additionalFields.fax;
                          }
                          if (additionalFields.email !== undefined) {
                              body.Email = additionalFields.email;
                          }
                          if (additionalFields.phone !== undefined) {
                              body.Phone = additionalFields.phone;
                          }
                          if (additionalFields.title !== undefined) {
                              body.Title = additionalFields.title;
                          }
                          if (additionalFields.jigsaw !== undefined) {
                              body.Jigsaw = additionalFields.jigsaw;
                          }
                          if (additionalFields.recordTypeId !== undefined) {
                              body.RecordTypeId = additionalFields.recordTypeId;
                          }
                          if (additionalFields.owner !== undefined) {
                              body.OwnerId = additionalFields.owner;
                          }
                          if (additionalFields.acconuntId !== undefined) {
                              body.AccountId = additionalFields.acconuntId;
                          }
                          if (additionalFields.birthdate !== undefined) {
                              body.Birthdate = additionalFields.birthdate;
                          }
                          if (additionalFields.firstName !== undefined) {
                              body.FirstName = additionalFields.firstName;
                          }
                          if (additionalFields.homePhone !== undefined) {
                              body.HomePhone = additionalFields.homePhone;
                          }
                          if (additionalFields.otherCity !== undefined) {
                              body.OtherCity = additionalFields.otherCity;
                          }
                          if (additionalFields.department !== undefined) {
                              body.Department = additionalFields.department;
                          }
                          if (additionalFields.leadSource !== undefined) {
                              body.LeadSource = additionalFields.leadSource;
                          }
                          if (additionalFields.otherPhone !== undefined) {
                              body.OtherPhone = additionalFields.otherPhone;
                          }
                          if (additionalFields.otherState !== undefined) {
                              body.OtherState = additionalFields.otherState;
                          }
                          if (additionalFields.salutation !== undefined) {
                              body.Salutation = additionalFields.salutation;
                          }
                          if (additionalFields.description !== undefined) {
                              body.Description = additionalFields.description;
                          }
                          if (additionalFields.mailingCity !== undefined) {
                              body.MailingCity = additionalFields.mailingCity;
                          }
                          if (additionalFields.mobilePhone !== undefined) {
                              body.MobilePhone = additionalFields.mobilePhone;
                          }
                          if (additionalFields.otherStreet !== undefined) {
                              body.OtherStreet = additionalFields.otherStreet;
                          }
                          if (additionalFields.mailingState !== undefined) {
                              body.MailingState = additionalFields.mailingState;
                          }
                          if (additionalFields.otherCountry !== undefined) {
                              body.OtherCountry = additionalFields.otherCountry;
                          }
                          if (additionalFields.assistantName !== undefined) {
                              body.AssistantName = additionalFields.assistantName;
                          }
                          if (additionalFields.mailingStreet !== undefined) {
                              body.MailingStreet = additionalFields.mailingStreet;
                          }
                          if (additionalFields.assistantPhone !== undefined) {
                              body.AssistantPhone = additionalFields.assistantPhone;
                          }
                          if (additionalFields.mailingCountry !== undefined) {
                              body.MailingCountry = additionalFields.mailingCountry;
                          }
                          if (additionalFields.otherPostalCode !== undefined) {
                              body.OtherPostalCode = additionalFields.otherPostalCode;
                          }
                          if (additionalFields.emailBouncedDate !== undefined) {
                              body.EmailBouncedDate = additionalFields.emailBouncedDate;
                          }
                          if (additionalFields.mailingPostalCode !== undefined) {
                              body.MailingPostalCode = additionalFields.mailingPostalCode;
                          }
                          if (additionalFields.emailBouncedReason !== undefined) {
                              body.EmailBouncedReason = additionalFields.emailBouncedReason;
                          }
                          if (additionalFields.customFieldsUi) {
                              const customFields = additionalFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          let endpoint = '/sobjects/contact';
                          let method = 'POST';
                          if (operation === 'upsert') {
                              method = 'PATCH';
                              const externalId = this.getNodeParameter('externalId', 0);
                              const externalIdValue = this.getNodeParameter('externalIdValue', i);
                              endpoint = `/sobjects/contact/${externalId}/${externalIdValue}`;
                              if (body[externalId] !== undefined) {
                                  delete body[externalId];
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, method, endpoint, body);
                      }
                      if (operation === 'update') {
                          const contactId = this.getNodeParameter('contactId', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {};
                          if (!Object.keys(updateFields).length) {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'You must add at least one update field', { itemIndex: i });
                          }
                          if (updateFields.lastName !== undefined) {
                              body.LastName = updateFields.lastName;
                          }
                          if (updateFields.fax !== undefined) {
                              body.Fax = updateFields.fax;
                          }
                          if (updateFields.email !== undefined) {
                              body.Email = updateFields.email;
                          }
                          if (updateFields.recordTypeId !== undefined) {
                              body.RecordTypeId = updateFields.recordTypeId;
                          }
                          if (updateFields.phone !== undefined) {
                              body.Phone = updateFields.phone;
                          }
                          if (updateFields.title !== undefined) {
                              body.Title = updateFields.title;
                          }
                          if (updateFields.jigsaw !== undefined) {
                              body.Jigsaw = updateFields.jigsaw;
                          }
                          if (updateFields.owner !== undefined) {
                              body.OwnerId = updateFields.owner;
                          }
                          if (updateFields.acconuntId !== undefined) {
                              body.AccountId = updateFields.acconuntId;
                          }
                          if (updateFields.birthdate !== undefined) {
                              body.Birthdate = updateFields.birthdate;
                          }
                          if (updateFields.firstName !== undefined) {
                              body.FirstName = updateFields.firstName;
                          }
                          if (updateFields.homePhone !== undefined) {
                              body.HomePhone = updateFields.homePhone;
                          }
                          if (updateFields.otherCity !== undefined) {
                              body.OtherCity = updateFields.otherCity;
                          }
                          if (updateFields.department !== undefined) {
                              body.Department = updateFields.department;
                          }
                          if (updateFields.leadSource !== undefined) {
                              body.LeadSource = updateFields.leadSource;
                          }
                          if (updateFields.otherPhone !== undefined) {
                              body.OtherPhone = updateFields.otherPhone;
                          }
                          if (updateFields.otherState !== undefined) {
                              body.OtherState = updateFields.otherState;
                          }
                          if (updateFields.salutation !== undefined) {
                              body.Salutation = updateFields.salutation;
                          }
                          if (updateFields.description !== undefined) {
                              body.Description = updateFields.description;
                          }
                          if (updateFields.mailingCity !== undefined) {
                              body.MailingCity = updateFields.mailingCity;
                          }
                          if (updateFields.mobilePhone !== undefined) {
                              body.MobilePhone = updateFields.mobilePhone;
                          }
                          if (updateFields.otherStreet !== undefined) {
                              body.OtherStreet = updateFields.otherStreet;
                          }
                          if (updateFields.mailingState !== undefined) {
                              body.MailingState = updateFields.mailingState;
                          }
                          if (updateFields.otherCountry !== undefined) {
                              body.OtherCountry = updateFields.otherCountry;
                          }
                          if (updateFields.assistantName !== undefined) {
                              body.AssistantName = updateFields.assistantName;
                          }
                          if (updateFields.mailingStreet !== undefined) {
                              body.MailingStreet = updateFields.mailingStreet;
                          }
                          if (updateFields.assistantPhone !== undefined) {
                              body.AssistantPhone = updateFields.assistantPhone;
                          }
                          if (updateFields.mailingCountry !== undefined) {
                              body.MailingCountry = updateFields.mailingCountry;
                          }
                          if (updateFields.otherPostalCode !== undefined) {
                              body.OtherPostalCode = updateFields.otherPostalCode;
                          }
                          if (updateFields.emailBouncedDate !== undefined) {
                              body.EmailBouncedDate = updateFields.emailBouncedDate;
                          }
                          if (updateFields.mailingPostalCode !== undefined) {
                              body.MailingPostalCode = updateFields.mailingPostalCode;
                          }
                          if (updateFields.emailBouncedReason !== undefined) {
                              body.EmailBouncedReason = updateFields.emailBouncedReason;
                          }
                          if (updateFields.customFieldsUi) {
                              const customFields = updateFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'PATCH', `/sobjects/contact/${contactId}`, body);
                      }
                      if (operation === 'get') {
                          const contactId = this.getNodeParameter('contactId', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/contact/${contactId}`);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          try {
                              if (returnAll) {
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Contact', returnAll);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                              else {
                                  const limit = this.getNodeParameter('limit', i);
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Contact', returnAll, limit);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'delete') {
                          const contactId = this.getNodeParameter('contactId', i);
                          try {
                              responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'DELETE', `/sobjects/contact/${contactId}`);
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'getSummary') {
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/contact');
                      }
                      if (operation === 'addToCampaign') {
                          const contactId = this.getNodeParameter('contactId', i);
                          const campaignId = this.getNodeParameter('campaignId', i);
                          const options = this.getNodeParameter('options', i);
                          const body = {
                              ContactId: contactId,
                              CampaignId: campaignId,
                          };
                          if (options.status) {
                              body.Status = options.status;
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/CampaignMember', body);
                      }
                      if (operation === 'addNote') {
                          const contactId = this.getNodeParameter('contactId', i);
                          const title = this.getNodeParameter('title', i);
                          const options = this.getNodeParameter('options', i);
                          const body = {
                              Title: title,
                              ParentId: contactId,
                          };
                          if (options.body !== undefined) {
                              body.Body = options.body;
                          }
                          if (options.owner !== undefined) {
                              body.OwnerId = options.owner;
                          }
                          if (options.isPrivate !== undefined) {
                              body.IsPrivate = options.isPrivate;
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/note', body);
                      }
                  }
                  if (resource === 'customObject') {
                      if (operation === 'create' || operation === 'upsert') {
                          const customObject = this.getNodeParameter('customObject', i);
                          const customFieldsUi = this.getNodeParameter('customFieldsUi', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const body = {};
                          if (customFieldsUi) {
                              const customFields = customFieldsUi.customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          if (additionalFields.recordTypeId) {
                              body.RecordTypeId = additionalFields.recordTypeId;
                          }
                          let endpoint = `/sobjects/${customObject}`;
                          let method = 'POST';
                          if (operation === 'upsert') {
                              method = 'PATCH';
                              const externalId = this.getNodeParameter('externalId', 0);
                              const externalIdValue = this.getNodeParameter('externalIdValue', i);
                              endpoint = `/sobjects/${customObject}/${externalId}/${externalIdValue}`;
                              if (body[externalId] !== undefined) {
                                  delete body[externalId];
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, method, endpoint, body);
                      }
                      if (operation === 'update') {
                          const recordId = this.getNodeParameter('recordId', i);
                          const customObject = this.getNodeParameter('customObject', i);
                          const customFieldsUi = this.getNodeParameter('customFieldsUi', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {};
                          if (updateFields.recordTypeId) {
                              body.RecordTypeId = updateFields.recordTypeId;
                          }
                          if (customFieldsUi) {
                              const customFields = customFieldsUi.customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'PATCH', `/sobjects/${customObject}/${recordId}`, body);
                      }
                      if (operation === 'get') {
                          const customObject = this.getNodeParameter('customObject', i);
                          const recordId = this.getNodeParameter('recordId', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/${customObject}/${recordId}`);
                      }
                      if (operation === 'getAll') {
                          const customObject = this.getNodeParameter('customObject', i);
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          try {
                              if (returnAll) {
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, customObject, returnAll);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                              else {
                                  const limit = this.getNodeParameter('limit', i);
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, customObject, returnAll, limit);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'delete') {
                          const customObject = this.getNodeParameter('customObject', i);
                          const recordId = this.getNodeParameter('recordId', i);
                          try {
                              responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'DELETE', `/sobjects/${customObject}/${recordId}`);
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                  }
                  if (resource === 'document') {
                      if (operation === 'upload') {
                          const title = this.getNodeParameter('title', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
                          const body = {
                              entity_content: {
                                  Title: title,
                                  ContentLocation: 'S',
                              },
                          };
                          if (additionalFields.ownerId) {
                              body.entity_content.ownerId = additionalFields.ownerId;
                          }
                          if (additionalFields.linkToObjectId) {
                              body.entity_content.FirstPublishLocationId =
                                  additionalFields.linkToObjectId;
                          }
                          const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
                          const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
                          body.entity_content.PathOnClient = `${title}.${additionalFields.fileExtension || binaryData.fileExtension}`;
                          const data = {
                              entity_content: {
                                  value: JSON.stringify(body.entity_content),
                                  options: {
                                      contentType: 'application/json',
                                  },
                              },
                              VersionData: {
                                  value: dataBuffer,
                                  options: {
                                      filename: body.entity_content.PathOnClient,
                                  },
                              },
                          };
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/ContentVersion', {}, {}, undefined, { formData: data });
                      }
                  }
                  if (resource === 'opportunity') {
                      if (operation === 'create' || operation === 'upsert') {
                          const name = this.getNodeParameter('name', i);
                          const closeDate = this.getNodeParameter('closeDate', i);
                          const stageName = this.getNodeParameter('stageName', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const body = {
                              Name: name,
                              CloseDate: closeDate,
                              StageName: stageName,
                          };
                          if (additionalFields.type !== undefined) {
                              body.Type = additionalFields.type;
                          }
                          if (additionalFields.amount !== undefined) {
                              body.Amount = additionalFields.amount;
                          }
                          if (additionalFields.owner !== undefined) {
                              body.OwnerId = additionalFields.owner;
                          }
                          if (additionalFields.nextStep !== undefined) {
                              body.NextStep = additionalFields.nextStep;
                          }
                          if (additionalFields.accountId !== undefined) {
                              body.AccountId = additionalFields.accountId;
                          }
                          if (additionalFields.campaignId !== undefined) {
                              body.CampaignId = additionalFields.campaignId;
                          }
                          if (additionalFields.leadSource !== undefined) {
                              body.LeadSource = additionalFields.leadSource;
                          }
                          if (additionalFields.description !== undefined) {
                              body.Description = additionalFields.description;
                          }
                          if (additionalFields.probability !== undefined) {
                              body.Probability = additionalFields.probability;
                          }
                          if (additionalFields.pricebook2Id !== undefined) {
                              body.Pricebook2Id = additionalFields.pricebook2Id;
                          }
                          if (additionalFields.forecastCategoryName !== undefined) {
                              body.ForecastCategoryName = additionalFields.forecastCategoryName;
                          }
                          if (additionalFields.customFieldsUi) {
                              const customFields = additionalFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          let endpoint = '/sobjects/opportunity';
                          let method = 'POST';
                          if (operation === 'upsert') {
                              method = 'PATCH';
                              const externalId = this.getNodeParameter('externalId', 0);
                              const externalIdValue = this.getNodeParameter('externalIdValue', i);
                              endpoint = `/sobjects/opportunity/${externalId}/${externalIdValue}`;
                              if (body[externalId] !== undefined) {
                                  delete body[externalId];
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, method, endpoint, body);
                      }
                      if (operation === 'update') {
                          const opportunityId = this.getNodeParameter('opportunityId', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {};
                          if (updateFields.name !== undefined) {
                              body.Name = updateFields.name;
                          }
                          if (updateFields.closeDate !== undefined) {
                              body.CloseDate = updateFields.closeDate;
                          }
                          if (updateFields.stageName !== undefined) {
                              body.StageName = updateFields.stageName;
                          }
                          if (updateFields.type !== undefined) {
                              body.Type = updateFields.type;
                          }
                          if (updateFields.amount !== undefined) {
                              body.Amount = updateFields.amount;
                          }
                          if (updateFields.owner !== undefined) {
                              body.OwnerId = updateFields.owner;
                          }
                          if (updateFields.nextStep !== undefined) {
                              body.NextStep = updateFields.nextStep;
                          }
                          if (updateFields.accountId !== undefined) {
                              body.AccountId = updateFields.accountId;
                          }
                          if (updateFields.campaignId !== undefined) {
                              body.CampaignId = updateFields.campaignId;
                          }
                          if (updateFields.leadSource !== undefined) {
                              body.LeadSource = updateFields.leadSource;
                          }
                          if (updateFields.description !== undefined) {
                              body.Description = updateFields.description;
                          }
                          if (updateFields.probability !== undefined) {
                              body.Probability = updateFields.probability;
                          }
                          if (updateFields.pricebook2Id !== undefined) {
                              body.Pricebook2Id = updateFields.pricebook2Id;
                          }
                          if (updateFields.forecastCategoryName !== undefined) {
                              body.ForecastCategoryName = updateFields.forecastCategoryName;
                          }
                          if (updateFields.customFieldsUi) {
                              const customFields = updateFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'PATCH', `/sobjects/opportunity/${opportunityId}`, body);
                      }
                      if (operation === 'get') {
                          const opportunityId = this.getNodeParameter('opportunityId', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/opportunity/${opportunityId}`);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          try {
                              if (returnAll) {
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Opportunity', returnAll);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                              else {
                                  const limit = this.getNodeParameter('limit', i);
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Opportunity', returnAll, limit);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'delete') {
                          const opportunityId = this.getNodeParameter('opportunityId', i);
                          try {
                              responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'DELETE', `/sobjects/opportunity/${opportunityId}`);
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'getSummary') {
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/opportunity');
                      }
                      if (operation === 'addNote') {
                          const opportunityId = this.getNodeParameter('opportunityId', i);
                          const title = this.getNodeParameter('title', i);
                          const options = this.getNodeParameter('options', i);
                          const body = {
                              Title: title,
                              ParentId: opportunityId,
                          };
                          if (options.body !== undefined) {
                              body.Body = options.body;
                          }
                          if (options.owner !== undefined) {
                              body.OwnerId = options.owner;
                          }
                          if (options.isPrivate !== undefined) {
                              body.IsPrivate = options.isPrivate;
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/note', body);
                      }
                  }
                  if (resource === 'account') {
                      if (operation === 'create' || operation === 'upsert') {
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const name = this.getNodeParameter('name', i);
                          const body = {
                              Name: name,
                          };
                          if (additionalFields.fax !== undefined) {
                              body.Fax = additionalFields.fax;
                          }
                          if (additionalFields.type !== undefined) {
                              body.Type = additionalFields.type;
                          }
                          if (additionalFields.jigsaw !== undefined) {
                              body.Jigsaw = additionalFields.jigsaw;
                          }
                          if (additionalFields.phone !== undefined) {
                              body.Phone = additionalFields.phone;
                          }
                          if (additionalFields.owner !== undefined) {
                              body.OwnerId = additionalFields.owner;
                          }
                          if (additionalFields.sicDesc !== undefined) {
                              body.SicDesc = additionalFields.sicDesc;
                          }
                          if (additionalFields.website !== undefined) {
                              body.Website = additionalFields.website;
                          }
                          if (additionalFields.industry !== undefined) {
                              body.Industry = additionalFields.industry;
                          }
                          if (additionalFields.parentId !== undefined) {
                              body.ParentId = additionalFields.parentId;
                          }
                          if (additionalFields.billingCity !== undefined) {
                              body.BillingCity = additionalFields.billingCity;
                          }
                          if (additionalFields.description !== undefined) {
                              body.Description = additionalFields.description;
                          }
                          if (additionalFields.billingState !== undefined) {
                              body.BillingState = additionalFields.billingState;
                          }
                          if (additionalFields.shippingCity !== undefined) {
                              body.ShippingCity = additionalFields.shippingCity;
                          }
                          if (additionalFields.accountNumber !== undefined) {
                              body.AccountNumber = additionalFields.accountNumber;
                          }
                          if (additionalFields.accountSource !== undefined) {
                              body.AccountSource = additionalFields.accountSource;
                          }
                          if (additionalFields.annualRevenue !== undefined) {
                              body.AnnualRevenue = additionalFields.annualRevenue;
                          }
                          if (additionalFields.billingStreet !== undefined) {
                              body.BillingStreet = additionalFields.billingStreet;
                          }
                          if (additionalFields.shippingState !== undefined) {
                              body.ShippingState = additionalFields.shippingState;
                          }
                          if (additionalFields.billingCountry !== undefined) {
                              body.BillingCountry = additionalFields.billingCountry;
                          }
                          if (additionalFields.shippingStreet !== undefined) {
                              body.ShippingStreet = additionalFields.shippingStreet;
                          }
                          if (additionalFields.shippingCountry !== undefined) {
                              body.ShippingCountry = additionalFields.shippingCountry;
                          }
                          if (additionalFields.billingPostalCode !== undefined) {
                              body.BillingPostalCode = additionalFields.billingPostalCode;
                          }
                          if (additionalFields.numberOfEmployees !== undefined) {
                              body.NumberOfEmployees = additionalFields.numberOfEmployees;
                          }
                          if (additionalFields.shippingPostalCode !== undefined) {
                              body.ShippingPostalCode = additionalFields.shippingPostalCode;
                          }
                          if (additionalFields.shippingPostalCode !== undefined) {
                              body.ShippingPostalCode = additionalFields.shippingPostalCode;
                          }
                          if (additionalFields.recordTypeId !== undefined) {
                              body.RecordTypeId = additionalFields.recordTypeId;
                          }
                          if (additionalFields.customFieldsUi) {
                              const customFields = additionalFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          let endpoint = '/sobjects/account';
                          let method = 'POST';
                          if (operation === 'upsert') {
                              method = 'PATCH';
                              const externalId = this.getNodeParameter('externalId', 0);
                              const externalIdValue = this.getNodeParameter('externalIdValue', i);
                              endpoint = `/sobjects/account/${externalId}/${externalIdValue}`;
                              if (body[externalId] !== undefined) {
                                  delete body[externalId];
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, method, endpoint, body);
                      }
                      if (operation === 'update') {
                          const accountId = this.getNodeParameter('accountId', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {};
                          if (updateFields.name !== undefined) {
                              body.Name = updateFields.name;
                          }
                          if (updateFields.fax !== undefined) {
                              body.Fax = updateFields.fax;
                          }
                          if (updateFields.type !== undefined) {
                              body.Type = updateFields.type;
                          }
                          if (updateFields.jigsaw !== undefined) {
                              body.Jigsaw = updateFields.jigsaw;
                          }
                          if (updateFields.phone !== undefined) {
                              body.Phone = updateFields.phone;
                          }
                          if (updateFields.ownerId !== undefined) {
                              body.OwnerId = updateFields.ownerId;
                          }
                          if (updateFields.sicDesc !== undefined) {
                              body.SicDesc = updateFields.sicDesc;
                          }
                          if (updateFields.recordTypeId !== undefined) {
                              body.RecordTypeId = updateFields.recordTypeId;
                          }
                          if (updateFields.website !== undefined) {
                              body.Website = updateFields.website;
                          }
                          if (updateFields.industry !== undefined) {
                              body.Industry = updateFields.industry;
                          }
                          if (updateFields.parentId !== undefined) {
                              body.ParentId = updateFields.parentId;
                          }
                          if (updateFields.billingCity !== undefined) {
                              body.BillingCity = updateFields.billingCity;
                          }
                          if (updateFields.description !== undefined) {
                              body.Description = updateFields.description;
                          }
                          if (updateFields.billingState !== undefined) {
                              body.BillingState = updateFields.billingState;
                          }
                          if (updateFields.shippingCity !== undefined) {
                              body.ShippingCity = updateFields.shippingCity;
                          }
                          if (updateFields.accountNumber !== undefined) {
                              body.AccountNumber = updateFields.accountNumber;
                          }
                          if (updateFields.accountSource !== undefined) {
                              body.AccountSource = updateFields.accountSource;
                          }
                          if (updateFields.annualRevenue !== undefined) {
                              body.AnnualRevenue = updateFields.annualRevenue;
                          }
                          if (updateFields.billingStreet !== undefined) {
                              body.BillingStreet = updateFields.billingStreet;
                          }
                          if (updateFields.shippingState !== undefined) {
                              body.ShippingState = updateFields.shippingState;
                          }
                          if (updateFields.billingCountry !== undefined) {
                              body.BillingCountry = updateFields.billingCountry;
                          }
                          if (updateFields.shippingStreet !== undefined) {
                              body.ShippingStreet = updateFields.shippingStreet;
                          }
                          if (updateFields.shippingCountry !== undefined) {
                              body.ShippingCountry = updateFields.shippingCountry;
                          }
                          if (updateFields.billingPostalCode !== undefined) {
                              body.BillingPostalCode = updateFields.billingPostalCode;
                          }
                          if (updateFields.numberOfEmployees !== undefined) {
                              body.NumberOfEmployees = updateFields.numberOfEmployees;
                          }
                          if (updateFields.shippingPostalCode !== undefined) {
                              body.ShippingPostalCode = updateFields.shippingPostalCode;
                          }
                          if (updateFields.shippingPostalCode !== undefined) {
                              body.ShippingPostalCode = updateFields.shippingPostalCode;
                          }
                          if (updateFields.customFieldsUi) {
                              const customFields = updateFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'PATCH', `/sobjects/account/${accountId}`, body);
                      }
                      if (operation === 'get') {
                          const accountId = this.getNodeParameter('accountId', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/account/${accountId}`);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          try {
                              if (returnAll) {
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Account', returnAll);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                              else {
                                  const limit = this.getNodeParameter('limit', i);
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Account', returnAll, limit);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'delete') {
                          const accountId = this.getNodeParameter('accountId', i);
                          try {
                              responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'DELETE', `/sobjects/account/${accountId}`);
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'getSummary') {
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/account');
                      }
                      if (operation === 'addNote') {
                          const accountId = this.getNodeParameter('accountId', i);
                          const title = this.getNodeParameter('title', i);
                          const options = this.getNodeParameter('options', i);
                          const body = {
                              Title: title,
                              ParentId: accountId,
                          };
                          if (options.body !== undefined) {
                              body.Body = options.body;
                          }
                          if (options.owner !== undefined) {
                              body.OwnerId = options.owner;
                          }
                          if (options.isPrivate !== undefined) {
                              body.IsPrivate = options.isPrivate;
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/note', body);
                      }
                  }
                  if (resource === 'case') {
                      if (operation === 'create') {
                          const type = this.getNodeParameter('type', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const body = {
                              Type: type,
                          };
                          if (additionalFields.origin !== undefined) {
                              body.Origin = additionalFields.origin;
                          }
                          if (additionalFields.reason !== undefined) {
                              body.Reason = additionalFields.reason;
                          }
                          if (additionalFields.status !== undefined) {
                              body.Status = additionalFields.status;
                          }
                          if (additionalFields.owner !== undefined) {
                              body.OwnerId = additionalFields.owner;
                          }
                          if (additionalFields.subject !== undefined) {
                              body.Subject = additionalFields.subject;
                          }
                          if (additionalFields.parentId !== undefined) {
                              body.ParentId = additionalFields.parentId;
                          }
                          if (additionalFields.priority !== undefined) {
                              body.Priority = additionalFields.priority;
                          }
                          if (additionalFields.accountId !== undefined) {
                              body.AccountId = additionalFields.accountId;
                          }
                          if (additionalFields.contactId !== undefined) {
                              body.ContactId = additionalFields.contactId;
                          }
                          if (additionalFields.description !== undefined) {
                              body.Description = additionalFields.description;
                          }
                          if (additionalFields.isEscalated !== undefined) {
                              body.IsEscalated = additionalFields.isEscalated;
                          }
                          if (additionalFields.suppliedName !== undefined) {
                              body.SuppliedName = additionalFields.suppliedName;
                          }
                          if (additionalFields.suppliedEmail !== undefined) {
                              body.SuppliedEmail = additionalFields.suppliedEmail;
                          }
                          if (additionalFields.suppliedPhone !== undefined) {
                              body.SuppliedPhone = additionalFields.suppliedPhone;
                          }
                          if (additionalFields.suppliedCompany !== undefined) {
                              body.SuppliedCompany = additionalFields.suppliedCompany;
                          }
                          if (additionalFields.recordTypeId !== undefined) {
                              body.RecordTypeId = additionalFields.recordTypeId;
                          }
                          if (additionalFields.customFieldsUi) {
                              const customFields = additionalFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/case', body);
                      }
                      if (operation === 'update') {
                          const caseId = this.getNodeParameter('caseId', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {};
                          if (updateFields.type !== undefined) {
                              body.Type = updateFields.type;
                          }
                          if (updateFields.origin !== undefined) {
                              body.Origin = updateFields.origin;
                          }
                          if (updateFields.reason !== undefined) {
                              body.Reason = updateFields.reason;
                          }
                          if (updateFields.status !== undefined) {
                              body.Status = updateFields.status;
                          }
                          if (updateFields.owner !== undefined) {
                              body.OwnerId = updateFields.owner;
                          }
                          if (updateFields.subject !== undefined) {
                              body.Subject = updateFields.subject;
                          }
                          if (updateFields.parentId !== undefined) {
                              body.ParentId = updateFields.parentId;
                          }
                          if (updateFields.priority !== undefined) {
                              body.Priority = updateFields.priority;
                          }
                          if (updateFields.accountId !== undefined) {
                              body.AccountId = updateFields.accountId;
                          }
                          if (updateFields.recordTypeId !== undefined) {
                              body.RecordTypeId = updateFields.recordTypeId;
                          }
                          if (updateFields.contactId !== undefined) {
                              body.ContactId = updateFields.contactId;
                          }
                          if (updateFields.description !== undefined) {
                              body.Description = updateFields.description;
                          }
                          if (updateFields.isEscalated !== undefined) {
                              body.IsEscalated = updateFields.isEscalated;
                          }
                          if (updateFields.suppliedName !== undefined) {
                              body.SuppliedName = updateFields.suppliedName;
                          }
                          if (updateFields.suppliedEmail !== undefined) {
                              body.SuppliedEmail = updateFields.suppliedEmail;
                          }
                          if (updateFields.suppliedPhone !== undefined) {
                              body.SuppliedPhone = updateFields.suppliedPhone;
                          }
                          if (updateFields.suppliedCompany !== undefined) {
                              body.SuppliedCompany = updateFields.suppliedCompany;
                          }
                          if (updateFields.customFieldsUi) {
                              const customFields = updateFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'PATCH', `/sobjects/case/${caseId}`, body);
                      }
                      if (operation === 'get') {
                          const caseId = this.getNodeParameter('caseId', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/case/${caseId}`);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          try {
                              if (returnAll) {
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Case', returnAll);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                              else {
                                  const limit = this.getNodeParameter('limit', i);
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Case', returnAll, limit);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'delete') {
                          const caseId = this.getNodeParameter('caseId', i);
                          try {
                              responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'DELETE', `/sobjects/case/${caseId}`);
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'getSummary') {
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/case');
                      }
                      if (operation === 'addComment') {
                          const caseId = this.getNodeParameter('caseId', i);
                          const options = this.getNodeParameter('options', i);
                          const body = {
                              ParentId: caseId,
                          };
                          if (options.commentBody !== undefined) {
                              body.CommentBody = options.commentBody;
                          }
                          if (options.isPublished !== undefined) {
                              body.IsPublished = options.isPublished;
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/casecomment', body);
                      }
                  }
                  if (resource === 'task') {
                      if (operation === 'create') {
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const status = this.getNodeParameter('status', i);
                          const body = {
                              Status: status,
                          };
                          if (additionalFields.type !== undefined) {
                              body.TaskSubtype = additionalFields.type;
                          }
                          if (additionalFields.whoId !== undefined) {
                              body.WhoId = additionalFields.whoId;
                          }
                          if (additionalFields.whatId !== undefined) {
                              body.WhatId = additionalFields.whatId;
                          }
                          if (additionalFields.owner !== undefined) {
                              body.OwnerId = additionalFields.owner;
                          }
                          if (additionalFields.subject !== undefined) {
                              body.Subject = additionalFields.subject;
                          }
                          if (additionalFields.callType !== undefined) {
                              body.CallType = additionalFields.callType;
                          }
                          if (additionalFields.priority !== undefined) {
                              body.Priority = additionalFields.priority;
                          }
                          if (additionalFields.callObject !== undefined) {
                              body.CallObject = additionalFields.callObject;
                          }
                          if (additionalFields.description !== undefined) {
                              body.Description = additionalFields.description;
                          }
                          if (additionalFields.activityDate !== undefined) {
                              body.ActivityDate = additionalFields.activityDate;
                          }
                          if (additionalFields.isReminderSet !== undefined) {
                              body.IsReminderSet = additionalFields.isReminderSet;
                          }
                          if (additionalFields.recurrenceType !== undefined) {
                              body.RecurrenceType = additionalFields.recurrenceType;
                          }
                          if (additionalFields.callDisposition !== undefined) {
                              body.CallDisposition = additionalFields.callDisposition;
                          }
                          if (additionalFields.reminderDateTime !== undefined) {
                              body.ReminderDateTime = additionalFields.reminderDateTime;
                          }
                          if (additionalFields.recurrenceInstance !== undefined) {
                              body.RecurrenceInstance = additionalFields.recurrenceInstance;
                          }
                          if (additionalFields.recurrenceInterval !== undefined) {
                              body.RecurrenceInterval = additionalFields.recurrenceInterval;
                          }
                          if (additionalFields.recurrenceDayOfMonth !== undefined) {
                              body.RecurrenceDayOfMonth = additionalFields.recurrenceDayOfMonth;
                          }
                          if (additionalFields.callDurationInSeconds !== undefined) {
                              body.CallDurationInSeconds = additionalFields.callDurationInSeconds;
                          }
                          if (additionalFields.recurrenceEndDateOnly !== undefined) {
                              body.RecurrenceEndDateOnly = additionalFields.recurrenceEndDateOnly;
                          }
                          if (additionalFields.recurrenceMonthOfYear !== undefined) {
                              body.RecurrenceMonthOfYear = additionalFields.recurrenceMonthOfYear;
                          }
                          if (additionalFields.recurrenceDayOfWeekMask !== undefined) {
                              body.RecurrenceDayOfWeekMask = additionalFields.recurrenceDayOfWeekMask;
                          }
                          if (additionalFields.recurrenceStartDateOnly !== undefined) {
                              body.RecurrenceStartDateOnly = additionalFields.recurrenceStartDateOnly;
                          }
                          if (additionalFields.recurrenceTimeZoneSidKey !== undefined) {
                              body.RecurrenceTimeZoneSidKey = additionalFields.recurrenceTimeZoneSidKey;
                          }
                          if (additionalFields.recurrenceRegeneratedType !== undefined) {
                              body.RecurrenceRegeneratedType = additionalFields.recurrenceRegeneratedType;
                          }
                          if (additionalFields.customFieldsUi) {
                              const customFields = additionalFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/task', body);
                      }
                      if (operation === 'update') {
                          const taskId = this.getNodeParameter('taskId', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {};
                          if (updateFields.type !== undefined) {
                              body.TaskSubtype = updateFields.type;
                          }
                          if (updateFields.whoId !== undefined) {
                              body.WhoId = updateFields.whoId;
                          }
                          if (updateFields.status !== undefined) {
                              body.Status = updateFields.status;
                          }
                          if (updateFields.whatId !== undefined) {
                              body.WhatId = updateFields.whatId;
                          }
                          if (updateFields.owner !== undefined) {
                              body.OwnerId = updateFields.owner;
                          }
                          if (updateFields.subject !== undefined) {
                              body.Subject = updateFields.subject;
                          }
                          if (updateFields.callType !== undefined) {
                              body.CallType = updateFields.callType;
                          }
                          if (updateFields.priority !== undefined) {
                              body.Priority = updateFields.priority;
                          }
                          if (updateFields.callObject !== undefined) {
                              body.CallObject = updateFields.callObject;
                          }
                          if (updateFields.description !== undefined) {
                              body.Description = updateFields.description;
                          }
                          if (updateFields.activityDate !== undefined) {
                              body.ActivityDate = updateFields.activityDate;
                          }
                          if (updateFields.isReminderSet !== undefined) {
                              body.IsReminderSet = updateFields.isReminderSet;
                          }
                          if (updateFields.recurrenceType !== undefined) {
                              body.RecurrenceType = updateFields.recurrenceType;
                          }
                          if (updateFields.callDisposition !== undefined) {
                              body.CallDisposition = updateFields.callDisposition;
                          }
                          if (updateFields.reminderDateTime !== undefined) {
                              body.ReminderDateTime = updateFields.reminderDateTime;
                          }
                          if (updateFields.recurrenceInstance !== undefined) {
                              body.RecurrenceInstance = updateFields.recurrenceInstance;
                          }
                          if (updateFields.recurrenceInterval !== undefined) {
                              body.RecurrenceInterval = updateFields.recurrenceInterval;
                          }
                          if (updateFields.recurrenceDayOfMonth !== undefined) {
                              body.RecurrenceDayOfMonth = updateFields.recurrenceDayOfMonth;
                          }
                          if (updateFields.callDurationInSeconds !== undefined) {
                              body.CallDurationInSeconds = updateFields.callDurationInSeconds;
                          }
                          if (updateFields.recurrenceEndDateOnly !== undefined) {
                              body.RecurrenceEndDateOnly = updateFields.recurrenceEndDateOnly;
                          }
                          if (updateFields.recurrenceMonthOfYear !== undefined) {
                              body.RecurrenceMonthOfYear = updateFields.recurrenceMonthOfYear;
                          }
                          if (updateFields.recurrenceDayOfWeekMask !== undefined) {
                              body.RecurrenceDayOfWeekMask = updateFields.recurrenceDayOfWeekMask;
                          }
                          if (updateFields.recurrenceStartDateOnly !== undefined) {
                              body.RecurrenceStartDateOnly = updateFields.recurrenceStartDateOnly;
                          }
                          if (updateFields.recurrenceTimeZoneSidKey !== undefined) {
                              body.RecurrenceTimeZoneSidKey = updateFields.recurrenceTimeZoneSidKey;
                          }
                          if (updateFields.recurrenceRegeneratedType !== undefined) {
                              body.RecurrenceRegeneratedType = updateFields.recurrenceRegeneratedType;
                          }
                          if (updateFields.customFieldsUi) {
                              const customFields = updateFields.customFieldsUi
                                  .customFieldsValues;
                              if (customFields) {
                                  for (const customField of customFields) {
                                      body[customField.fieldId] = customField.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'PATCH', `/sobjects/task/${taskId}`, body);
                      }
                      if (operation === 'get') {
                          const taskId = this.getNodeParameter('taskId', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/task/${taskId}`);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          try {
                              if (returnAll) {
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Task', returnAll);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                              else {
                                  const limit = this.getNodeParameter('limit', i);
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Task', returnAll, limit);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'delete') {
                          const taskId = this.getNodeParameter('taskId', i);
                          try {
                              responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'DELETE', `/sobjects/task/${taskId}`);
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'getSummary') {
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/task');
                      }
                  }
                  if (resource === 'attachment') {
                      if (operation === 'create') {
                          const name = this.getNodeParameter('name', i);
                          const parentId = this.getNodeParameter('parentId', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
                          const body = {
                              Name: name,
                              ParentId: parentId,
                          };
                          if (items[i].binary && items[i].binary[binaryPropertyName]) {
                              body.Body = items[i].binary[binaryPropertyName].data;
                              body.ContentType = items[i].binary[binaryPropertyName].mimeType;
                          }
                          else {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The property ${binaryPropertyName} does not exist`, { itemIndex: i });
                          }
                          if (additionalFields.description !== undefined) {
                              body.Description = additionalFields.description;
                          }
                          if (additionalFields.owner !== undefined) {
                              body.OwnerId = additionalFields.owner;
                          }
                          if (additionalFields.isPrivate !== undefined) {
                              body.IsPrivate = additionalFields.isPrivate;
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', '/sobjects/attachment', body);
                      }
                      if (operation === 'update') {
                          const attachmentId = this.getNodeParameter('attachmentId', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {};
                          if (updateFields.binaryPropertyName !== undefined) {
                              const binaryPropertyName = updateFields.binaryPropertyName;
                              if (items[i].binary && items[i].binary[binaryPropertyName]) {
                                  body.Body = items[i].binary[binaryPropertyName].data;
                                  body.ContentType = items[i].binary[binaryPropertyName].mimeType;
                              }
                              else {
                                  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The property ${binaryPropertyName} does not exist`, { itemIndex: i });
                              }
                          }
                          if (updateFields.name !== undefined) {
                              body.Name = updateFields.name;
                          }
                          if (updateFields.description !== undefined) {
                              body.Description = updateFields.description;
                          }
                          if (updateFields.owner !== undefined) {
                              body.OwnerId = updateFields.owner;
                          }
                          if (updateFields.isPrivate !== undefined) {
                              body.IsPrivate = updateFields.isPrivate;
                          }
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'PATCH', `/sobjects/attachment/${attachmentId}`, body);
                      }
                      if (operation === 'get') {
                          const attachmentId = this.getNodeParameter('attachmentId', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/attachment/${attachmentId}`);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          try {
                              if (returnAll) {
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Attachment', returnAll);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                              else {
                                  const limit = this.getNodeParameter('limit', i);
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'Attachment', returnAll, limit);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'delete') {
                          const attachmentId = this.getNodeParameter('attachmentId', i);
                          try {
                              responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'DELETE', `/sobjects/attachment/${attachmentId}`);
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                      if (operation === 'getSummary') {
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/sobjects/attachment');
                      }
                  }
                  if (resource === 'user') {
                      if (operation === 'get') {
                          const userId = this.getNodeParameter('userId', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', `/sobjects/user/${userId}`);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          try {
                              if (returnAll) {
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'User', returnAll);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                              else {
                                  const limit = this.getNodeParameter('limit', i);
                                  qs.q = (0, GenericFunctions_1.getQuery)(options, 'User', returnAll, limit);
                                  responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                              }
                          }
                          catch (error) {
                              throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                          }
                      }
                  }
                  if (resource === 'flow') {
                      if (operation === 'invoke') {
                          const apiName = this.getNodeParameter('apiName', i);
                          const jsonParameters = this.getNodeParameter('jsonParameters', i);
                          let variables = {};
                          if (jsonParameters) {
                              variables = this.getNodeParameter('variablesJson', i);
                          }
                          else {
                              const setInputVariable = this.getNodeParameter('variablesUi', i, {});
                              if (setInputVariable.variablesValues !== undefined) {
                                  for (const inputVariableData of setInputVariable.variablesValues) {
                                      variables[inputVariableData.name] = inputVariableData.value;
                                  }
                              }
                          }
                          const body = {
                              inputs: [variables],
                          };
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'POST', `/actions/custom/flow/${apiName}`, body);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          responseData = await GenericFunctions_1.salesforceApiRequest.call(this, 'GET', '/actions/custom/flow');
                          responseData = responseData.actions;
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = responseData.splice(0, limit);
                          }
                      }
                  }
                  if (resource === 'search') {
                      if (operation === 'query') {
                          qs.q = this.getNodeParameter('query', i);
                          responseData = await GenericFunctions_1.salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
                      }
                  }
                  if (!Array.isArray(responseData) && responseData === undefined) {
                      responseData = {
                          errors: [],
                          success: true,
                      };
                  }
                  const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                  returnData.push(...executionData);
              }
              catch (error) {
                  if (this.continueOnFail()) {
                      const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                      returnData.push(...executionErrorData);
                      continue;
                  }
                  throw error;
              }
          }
          return [returnData];
      }
  }
  exports.Salesforce = Salesforce;
  //# sourceMappingURL=Salesforce.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Salesforce Trigger node documentation
  description: Learn how to use the Salesforce Trigger node in n8n. Follow technical documentation to integrate Salesforce Trigger node into your workflows.
  contentType: [integration, reference]
  priority: medium
  ---

  # Salesforce Trigger node

  Use the Salesforce Trigger node to respond to events in [Salesforce](https://login.salesforce.com/){:target=_blank .external-link} and integrate Salesforce with other applications. n8n has built-in support for a wide range of Salesforce events.

  On this page, you'll find a list of events the Salesforce Trigger node can respond to, and links to more resources.

  ///  note  | Credentials
  You can find authentication information for this node [here](/integrations/builtin/credentials/salesforce.md).
  ///
  ///  note  | Examples and templates
  For usage examples and templates to help you get started, refer to n8n's [Salesforce trigger integrations](https://n8n.io/integrations/salesforce-trigger/){:target=_blank .external-link} page.
  ///

  ## Events

  * On Account Created
  * On Account Updated
  * On Attachment Created
  * On Attachment Updated
  * On Case Created
  * On Case Updated
  * On Contact Created
  * On Contact Updated
  * On Custom Object Created
  * On Custom Object Updated
  * On Lead Created
  * On Lead Updated
  * On Opportunity Created
  * On Opportunity Updated
  * On Task Created
  * On Task Updated
  * On User Created
  * On User Updated

  ## Related resources

  n8n provides an app node for Salesforce. You can find the node docs [here](/integrations/builtin/app-nodes/n8n-nodes-base.salesforce.md).

  View [example workflows and related content](https://n8n.io/integrations/salesforce-trigger/){:target=_blank .external-link} on n8n's website.

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"79d3953e-5531-4ba9-b84f-260494d58ed6","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"305fb25a8a774d734ca9b5aa09118653905d482efefb22ea643d99f077c69330"}}


node_type: n8n-nodes-base.Salesmate
name: Salesmate
display_name: Salesmate
description: Consume Salesmate API
category: output
icon: file:salesmate.png
code_hash: ac0be2ad778e6daabce9912980fc92e4f611c33f6c7b4e7ba0ee80316f412075
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.salesmate
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 09:18:26
updated_at: 2025-06-08 09:18:26
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Salesmate = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const GenericFunctions_1 = require("./GenericFunctions");
  const CompanyDescription_1 = require("./CompanyDescription");
  const ActivityDescription_1 = require("./ActivityDescription");
  const DealDescription_1 = require("./DealDescription");
  class Salesmate {
      constructor() {
          this.description = {
              displayName: 'Salesmate',
              name: 'salesmate',
              icon: 'file:salesmate.png',
              group: ['output'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ":" + $parameter["resource"]}}',
              description: 'Consume Salesmate API',
              defaults: {
                  name: 'Salesmate',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'salesmateApi',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Activity',
                              value: 'activity',
                          },
                          {
                              name: 'Company',
                              value: 'company',
                          },
                          {
                              name: 'Deal',
                              value: 'deal',
                          },
                      ],
                      default: 'activity',
                  },
                  ...CompanyDescription_1.companyOperations,
                  ...ActivityDescription_1.activityOperations,
                  ...DealDescription_1.dealOperations,
                  ...CompanyDescription_1.companyFields,
                  ...ActivityDescription_1.activityFields,
                  ...DealDescription_1.dealFields,
              ],
          };
          this.methods = {
              loadOptions: {
                  async getUsers() {
                      const returnData = [];
                      const users = await GenericFunctions_1.salesmateApiRequest.call(this, 'GET', '/v1/users/active');
                      for (const user of users.Data) {
                          const userName = user.nickname;
                          const userId = user.id;
                          returnData.push({
                              name: userName,
                              value: userId,
                          });
                      }
                      return returnData;
                  },
                  async getContacts() {
                      const returnData = [];
                      const qs = {
                          fields: ['name', 'id'],
                          query: {},
                      };
                      const contacts = await GenericFunctions_1.salesmateApiRequest.call(this, 'POST', '/v2/contacts/search', qs);
                      for (const contact of contacts.Data.data) {
                          const contactName = contact.name;
                          const contactId = contact.id;
                          returnData.push({
                              name: contactName,
                              value: contactId,
                          });
                      }
                      return returnData;
                  },
                  async getCompanies() {
                      const returnData = [];
                      const qs = {
                          fields: ['name', 'id'],
                          query: {},
                      };
                      const companies = await GenericFunctions_1.salesmateApiRequest.call(this, 'POST', '/v2/companies/search', qs);
                      for (const company of companies.Data.data) {
                          const companyName = company.name;
                          const companyId = company.id;
                          returnData.push({
                              name: companyName,
                              value: companyId,
                          });
                      }
                      return returnData;
                  },
              },
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          const length = items.length;
          const qs = {};
          let responseData;
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          for (let i = 0; i < length; i++) {
              if (resource === 'company') {
                  if (operation === 'create') {
                      const owner = this.getNodeParameter('owner', i);
                      const name = this.getNodeParameter('name', i);
                      const rawData = this.getNodeParameter('rawData', i);
                      const additionalFields = this.getNodeParameter('additionalFields', i);
                      const body = {
                          name,
                          owner,
                      };
                      if (additionalFields.website) {
                          body.website = additionalFields.website;
                      }
                      if (additionalFields.phone) {
                          body.phone = additionalFields.phone;
                      }
                      if (additionalFields.otherPhone) {
                          body.otherPhone = additionalFields.otherPhone;
                      }
                      if (additionalFields.facebookHandle) {
                          body.facebookHandle = additionalFields.facebookHandle;
                      }
                      if (additionalFields.googlePlusHandle) {
                          body.googlePlusHandle = additionalFields.googlePlusHandle;
                      }
                      if (additionalFields.linkedInHandle) {
                          body.linkedInHandle = additionalFields.linkedInHandle;
                      }
                      if (additionalFields.skypeId) {
                          body.skypeId = additionalFields.skypeId;
                      }
                      if (additionalFields.twitterHandle) {
                          body.twitterHandle = additionalFields.twitterHandle;
                      }
                      if (additionalFields.currency) {
                          body.currency = additionalFields.currency;
                      }
                      if (additionalFields.billingAddressLine1) {
                          body.billingAddressLine1 = additionalFields.billingAddressLine1;
                      }
                      if (additionalFields.billingAddressLine2) {
                          body.billingAddressLine2 = additionalFields.billingAddressLine2;
                      }
                      if (additionalFields.billingCity) {
                          body.billingCity = additionalFields.billingCity;
                      }
                      if (additionalFields.billingZipCode) {
                          body.billingZipCode = additionalFields.billingZipCode;
                      }
                      if (additionalFields.billingState) {
                          body.billingState = additionalFields.billingState;
                      }
                      if (additionalFields.description) {
                          body.description = additionalFields.description;
                      }
                      if (additionalFields.tags) {
                          body.tags = additionalFields.tags;
                      }
                      responseData = await GenericFunctions_1.salesmateApiRequest.call(this, 'POST', '/v1/companies', body);
                      responseData = responseData.Data;
                      if (!rawData) {
                          delete responseData.detail;
                      }
                  }
                  if (operation === 'update') {
                      const companyId = this.getNodeParameter('id', i);
                      const updateFields = this.getNodeParameter('updateFields', i);
                      const rawData = this.getNodeParameter('rawData', i);
                      const body = {};
                      if (updateFields.owner) {
                          body.owner = updateFields.owner;
                      }
                      if (updateFields.name) {
                          body.name = updateFields.name;
                      }
                      if (updateFields.website) {
                          body.website = updateFields.website;
                      }
                      if (updateFields.phone) {
                          body.phone = updateFields.phone;
                      }
                      if (updateFields.otherPhone) {
                          body.otherPhone = updateFields.otherPhone;
                      }
                      if (updateFields.facebookHandle) {
                          body.facebookHandle = updateFields.facebookHandle;
                      }
                      if (updateFields.googlePlusHandle) {
                          body.googlePlusHandle = updateFields.googlePlusHandle;
                      }
                      if (updateFields.linkedInHandle) {
                          body.linkedInHandle = updateFields.linkedInHandle;
                      }
                      if (updateFields.skypeId) {
                          body.skypeId = updateFields.skypeId;
                      }
                      if (updateFields.twitterHandle) {
                          body.twitterHandle = updateFields.twitterHandle;
                      }
                      if (updateFields.currency) {
                          body.currency = updateFields.currency;
                      }
                      if (updateFields.billingAddressLine1) {
                          body.billingAddressLine1 = updateFields.billingAddressLine1;
                      }
                      if (updateFields.billingAddressLine2) {
                          body.billingAddressLine2 = updateFields.billingAddressLine2;
                      }
                      if (updateFields.billingCity) {
                          body.billingCity = updateFields.billingCity;
                      }
                      if (updateFields.billingZipCode) {
                          body.billingZipCode = updateFields.billingZipCode;
                      }
                      if (updateFields.billingState) {
                          body.billingState = updateFields.billingState;
                      }
                      if (updateFields.description) {
                          body.description = updateFields.description;
                      }
                      if (updateFields.tags) {
                          body.tags = updateFields.tags;
                      }
                      responseData = await GenericFunctions_1.salesmateApiRequest.call(this, 'PUT', `/v1/companies/${companyId}`, body);
                      responseData = responseData.Data;
                      if (!rawData) {
                          delete responseData.detail;
                      }
                  }
                  if (operation === 'get') {
                      const companyId = this.getNodeParameter('id', i);
                      const rawData = this.getNodeParameter('rawData', i);
                      responseData = await GenericFunctions_1.salesmateApiRequest.call(this, 'GET', `/v1/companies/${companyId}`);
                      responseData = responseData.Data;
                      if (!rawData) {
                          responseData = (0, GenericFunctions_1.simplifySalesmateData)(responseData);
                      }
                  }
                  if (operation === 'getAll') {
                      const returnAll = this.getNodeParameter('returnAll', i);
                      const options = this.getNodeParameter('options', i);
                      const jsonActive = this.getNodeParameter('jsonParameters', i);
                      let body = {
                          query: {
                              group: {},
                          },
                      };
                      if (options.sortBy) {
                          qs.sortBy = options.sortBy;
                      }
                      if (options.sortOrder) {
                          qs.sortOrder = options.sortOrder;
                      }
                      if (options.fields) {
                          if (options.fields.trim() === '') {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'You have to add at least one field', {
                                  itemIndex: i,
                              });
                          }
                          body.fields = options.fields.split(',');
                      }
                      else {
                          body.fields = [
                              'name',
                              'description',
                              'billingAddressLine1',
                              'billingAddressLine2',
                              'billingCity',
                              'billingZipCode',
                              'billingState',
                              'billingCountry',
                              'website',
                              'owner',
                              'tags',
                              'photo',
                              'createdAt',
                          ];
                      }
                      if (!jsonActive) {
                          const filters = [];
                          const filtersUi = this.getNodeParameter('filters', i).filtersUi;
                          if (filtersUi === null || filtersUi === void 0 ? void 0 : filtersUi.conditions) {
                              const conditions = filtersUi.conditions;
                              if (conditions.conditionsUi) {
                                  for (const condition of conditions.conditionsUi) {
                                      const filter = {};
                                      filter.moduleName = 'Company';
                                      filter.field = {
                                          fieldName: condition.field,
                                      };
                                      filter.condition = condition.condition;
                                      filter.data = condition.value;
                                      filters.push(filter);
                                  }
                              }
                          }
                          if (filtersUi === null || filtersUi === void 0 ? void 0 : filtersUi.operator) {
                              body.query.group = {
                                  operator: filtersUi.operator,
                                  rules: filters,
                              };
                          }
                      }
                      else {
                          const json = (0, GenericFunctions_1.validateJSON)(this.getNodeParameter('filtersJson', i));
                          body = json;
                      }
                      if (returnAll) {
                          responseData = await GenericFunctions_1.salesmateApiRequestAllItems.call(this, 'Data', 'POST', '/v2/companies/search', body, qs);
                      }
                      else {
                          const limit = this.getNodeParameter('limit', i);
                          qs.rows = limit;
                          responseData = await GenericFunctions_1.salesmateApiRequest.call(this, 'POST', '/v2/companies/search', body, qs);
                          responseData = responseData.Data.data;
                      }
                  }
                  if (operation === 'delete') {
                      const companyId = parseInt(this.getNodeParameter('id', i), 10);
                      responseData = await GenericFunctions_1.salesmateApiRequest.call(this, 'DELETE', `/v1/companies/${companyId}`);
                  }
              }
              if (resource === 'activity') {
                  if (operation === 'create') {
                      const owner = this.getNodeParameter('owner', i);
                      const title = this.getNodeParameter('title', i);
                      const type = this.getNodeParameter('type', i);
                      const rawData = this.getNodeParameter('rawData', i);
                      const additionalFields = this.getNodeParameter('additionalFields', i);
                      const body = {
                          title,
                          owner,
                          type,
                      };
                      if (additionalFields.dueDate) {
                          body.dueDate = new Date(additionalFields.dueDate).getTime();
                      }
                      if (additionalFields.duration) {
                          body.duration = additionalFields.duration;
                      }
                      if (additionalFields.isCalendarInvite) {
                          body.isCalendarInvite = additionalFields.isCalendarInvite;
                      }
                      if (additionalFields.isCompleted) {
                          body.isCompleted = additionalFields.isCompleted;
                      }
                      if (additionalFields.description) {
                          body.description = additionalFields.description;
                      }
                      if (additionalFields.tags) {
                          body.tags = additionalFields.tags;
                      }
                      responseData = await GenericFunctions_1.salesmateApiRequest.call(this, 'POST', '/v1/activities', body);
                      responseData = responseData.Data;
                      if (!rawData) {
                          delete responseData.detail;
                      }
                  }
                  if (operation === 'update') {
                      const activityId = this.getNodeParameter('id', i);
                      const rawData = this.getNodeParameter('rawData', i);
                      const updateFields = this.getNodeParameter('updateFields', i);
                      const body = {};
                      if (updateFields.title) {
                          body.title = updateFields.title;
                      }
                      if (updateFields.type) {
                          body.type = updateFields.type;
                      }
                      if (updateFields.owner) {
                          body.owner = updateFields.owner;
                      }
                      if (updateFields.dueDate) {
                          body.dueDate = new Date(updateFields.dueDate).getTime();
                      }
                      if (updateFields.duration) {
                          body.duration = updateFields.duration;
                      }
                      if (updateFields.isCalendarInvite) {
                          body.isCalendarInvite = updateFields.isCalendarInvite;
                      }
                      if (updateFields.isCompleted) {
                          body.isCompleted = updateFields.isCompleted;
                      }
                      if (updateFields.description) {
                          body.description = updateFields.description;
                      }
                      if (updateFields.tags) {
                          body.tags = updateFields.tags;
                      }
                      responseData = await GenericFunctions_1.salesmateApiRequest.call(this, 'PUT', `/v1/activities/${activityId}`, body);
                      responseData = responseData.Data;
                      if (!rawData) {
                          delete responseData.detail;
                      }
                  }
                  if (operation === 'get') {
                      const activityId = this.getNodeParameter('id', i);
                      const rawData = this.getNodeParameter('rawData', i);
                      responseData = await GenericFunctions_1.salesmateApiRequest.call(this, 'GET', `/v1/activities/${activityId}`);
                      responseData = responseData.Data;
                      if (!rawData) {
                          responseData = (0, GenericFunctions_1.simplifySalesmateData)(responseData);
                      }
                  }
                  if (operation === 'getAll') {
                      const returnAll = this.getNodeParameter('returnAll', i);
                      const options = this.getNodeParameter('options', i);
                      const jsonActive = this.getNodeParameter('jsonParameters', i);
                      let body = {
                          query: {
                              group: {},
                          },
                      };
                      if (options.sortBy) {
                          qs.sortBy = options.sortBy;
                      }
                      if (options.sortOrder) {
                          qs.sortOrder = options.sortOrder;
                      }
                      if (options.fields) {
                          if (options.fields.trim() === '') {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'You have to add at least one field', {
                                  itemIndex: i,
                              });
                          }
                          body.fields = options.fields.split(',');
                      }
                      else {
                          body.fields = [
                              'title',
                              'dueDate',
                              'description',
                              'duration',
                              'owner',
                              'Deal.title',
                              'PrimaryContact.name',
                              'PrimaryContact.email',
                              'PrimaryCompany.name',
                              'PrimaryCompany.email',
                              'tags',
                              'type',
                              'createdAt',
                              'isCompleted',
                          ];
                      }
                      if (!jsonActive) {
                          const filters = [];
                          const filtersUi = this.getNodeParameter('filters', i).filtersUi;
                          if (filtersUi === null || filtersUi === void 0 ? void 0 : filtersUi.conditions) {
                              const conditions = filtersUi.conditions;
                              if (conditions.conditionsUi) {
                                  for (const condition of conditions.conditionsUi) {
                                      const filter = {};
                                      filter.moduleName = 'Task';
                                      filter.field = {
                                          fieldName: condition.field,
                                      };
                                      filter.condition = condition.condition;
                                      filter.data = condition.value;
                                      filters.push(filter);
                                  }
                              }
                          }
                          if (filtersUi === null || filtersUi === void 0 ? void 0 : filtersUi.operator) {
                              body.query.group = {
                                  operator: filtersUi.operator,
                                  rules: filters,
                              };
                          }
                      }
                      else {
                          const json = (0, GenericFunctions_1.validateJSON)(this.getNodeParameter('filtersJson', i));
                          body = json;
                      }
                      if (returnAll) {
                          responseData = await GenericFunctions_1.salesmateApiRequestAllItems.call(this, 'Data', 'POST', '/v2/activities/search', body, qs);
                      }
                      else {
                          const limit = this.getNodeParameter('limit', i);
                          qs.rows = limit;
                          responseData = await GenericFunctions_1.salesmateApiRequest.call(this, 'POST', '/v2/activities/search', body, qs);
                          responseData = responseData.Data.data;
                      }
                  }
                  if (operation === 'delete') {
                      const activityId = this.getNodeParameter('id', i);
                      responseData = await GenericFunctions_1.salesmateApiRequest.call(this, 'DELETE', `/v1/activities/${activityId}`);
                  }
              }
              if (resource === 'deal') {
                  if (operation === 'create') {
                      const title = this.getNodeParameter('title', i);
                      const owner = this.getNodeParameter('owner', i);
                      const primaryContact = this.getNodeParameter('primaryContact', i);
                      const pipeline = this.getNodeParameter('pipeline', i);
                      const status = this.getNodeParameter('status', i);
                      const stage = this.getNodeParameter('stage', i);
                      const currency = this.getNodeParameter('currency', i);
                      const rawData = this.getNodeParameter('rawData', i);
                      const additionalFields = this.getNodeParameter('additionalFields', i);
                      const body = {
                          title,
                          owner,
                          primaryContact,
                          pipeline,
                          status,
                          stage,
                          currency,
                      };
                      if (additionalFields.description) {
                          body.description = additionalFields.description;
                      }
                      if (additionalFields.tags) {
                          body.tags = additionalFields.tags;
                      }
                      if (additionalFields.primaryCompany) {
                          body.primaryCompany = additionalFields.primaryCompany;
                      }
                      if (additionalFields.source) {
                          body.source = additionalFields.source;
                      }
                      if (additionalFields.estimatedCloseDate) {
                          body.estimatedCloseDate = additionalFields.estimatedCloseDate;
                      }
                      if (additionalFields.dealValue) {
                          body.dealValue = additionalFields.dealValue;
                      }
                      if (additionalFields.priority) {
                          body.priority = additionalFields.priority;
                      }
                      responseData = await GenericFunctions_1.salesmateApiRequest.call(this, 'POST', '/v1/deals', body);
                      responseData = responseData.Data;
                      if (!rawData) {
                          delete responseData.detail;
                      }
                  }
                  if (operation === 'update') {
                      const dealId = this.getNodeParameter('id', i);
                      const rawData = this.getNodeParameter('rawData', i);
                      const updateFields = this.getNodeParameter('updateFields', i);
                      const body = {};
                      if (updateFields.title) {
                          body.title = updateFields.title;
                      }
                      if (updateFields.owner) {
                          body.owner = updateFields.owner;
                      }
                      if (updateFields.primaryContact) {
                          body.primaryContact = updateFields.primaryContact;
                      }
                      if (updateFields.status) {
                          body.status = updateFields.status;
                      }
                      if (updateFields.currency) {
                          body.currency = updateFields.currency;
                      }
                      if (updateFields.stage) {
                          body.stage = updateFields.stage;
                      }
                      if (updateFields.pipeline) {
                          body.pipeline = updateFields.pipeline;
                      }
                      if (updateFields.description) {
                          body.description = updateFields.description;
                      }
                      if (updateFields.tags) {
                          body.tags = updateFields.tags;
                      }
                      if (updateFields.primaryCompany) {
                          body.primaryCompany = updateFields.primaryCompany;
                      }
                      if (updateFields.source) {
                          body.source = updateFields.source;
                      }
                      if (updateFields.estimatedCloseDate) {
                          body.estimatedCloseDate = updateFields.estimatedCloseDate;
                      }
                      if (updateFields.dealValue) {
                          body.dealValue = updateFields.dealValue;
                      }
                      if (updateFields.priority) {
                          body.priority = updateFields.priority;
                      }
                      responseData = await GenericFunctions_1.salesmateApiRequest.call(this, 'PUT', `/v1/deals/${dealId}`, body);
                      responseData = responseData.Data;
                      if (!rawData) {
                          delete responseData.detail;
                      }
                  }
                  if (operation === 'get') {
                      const dealId = this.getNodeParameter('id', i);
                      const rawData = this.getNodeParameter('rawData', i);
                      responseData = await GenericFunctions_1.salesmateApiRequest.call(this, 'GET', `/v1/deals/${dealId}`);
                      responseData = responseData.Data;
                      if (!rawData) {
                          responseData = (0, GenericFunctions_1.simplifySalesmateData)(responseData);
                      }
                  }
                  if (operation === 'getAll') {
                      const returnAll = this.getNodeParameter('returnAll', i);
                      const options = this.getNodeParameter('options', i);
                      const jsonActive = this.getNodeParameter('jsonParameters', i);
                      let body = {
                          query: {
                              group: {},
                          },
                      };
                      if (options.sortBy) {
                          qs.sortBy = options.sortBy;
                      }
                      if (options.sortOrder) {
                          qs.sortOrder = options.sortOrder;
                      }
                      if (options.fields !== undefined) {
                          if (options.fields.trim() === '') {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'You have to add at least one field', {
                                  itemIndex: i,
                              });
                          }
                          body.fields = options.fields.split(',');
                      }
                      else {
                          body.fields = [
                              'title',
                              'PrimaryContact.name',
                              'PrimaryContact.email',
                              'PrimaryCompany.name',
                              'PrimaryCompany.email',
                              'dealValue',
                              'priority',
                              'stage',
                              'status',
                              'owner',
                              'tags',
                              'createdAt',
                          ];
                      }
                      if (!jsonActive) {
                          const filters = [];
                          const filtersUi = this.getNodeParameter('filters', i).filtersUi;
                          if (filtersUi === null || filtersUi === void 0 ? void 0 : filtersUi.conditions) {
                              const conditions = filtersUi.conditions;
                              if (conditions.conditionsUi) {
                                  for (const condition of conditions.conditionsUi) {
                                      const filter = {};
                                      filter.moduleName = 'Task';
                                      filter.field = {
                                          fieldName: condition.field,
                                      };
                                      filter.condition = condition.condition;
                                      filter.data = condition.value;
                                      filters.push(filter);
                                  }
                              }
                          }
                          if (filtersUi === null || filtersUi === void 0 ? void 0 : filtersUi.operator) {
                              body.query.group = {
                                  operator: filtersUi.operator,
                                  rules: filters,
                              };
                          }
                      }
                      else {
                          const json = (0, GenericFunctions_1.validateJSON)(this.getNodeParameter('filtersJson', i));
                          body = json;
                      }
                      if (returnAll) {
                          responseData = await GenericFunctions_1.salesmateApiRequestAllItems.call(this, 'Data', 'POST', '/v2/deals/search', body, qs);
                      }
                      else {
                          const limit = this.getNodeParameter('limit', i);
                          qs.rows = limit;
                          responseData = await GenericFunctions_1.salesmateApiRequest.call(this, 'POST', '/v2/deals/search', body, qs);
                          responseData = responseData.Data.data;
                      }
                  }
                  if (operation === 'delete') {
                      const dealId = this.getNodeParameter('id', i);
                      responseData = await GenericFunctions_1.salesmateApiRequest.call(this, 'DELETE', `/v1/deals/${dealId}`);
                  }
              }
              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
              returnData.push(...executionData);
          }
          return [returnData];
      }
  }
  exports.Salesmate = Salesmate;
  //# sourceMappingURL=Salesmate.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Salesmate node documentation
  description: Learn how to use the Salesmate node in n8n. Follow technical documentation to integrate Salesmate node into your workflows.
  contentType: [integration, reference]
  ---

  # Salesmate node

  Use the Salesmate node to automate work in Salesmate, and integrate Salesmate with other applications. n8n has built-in support for a wide range of Salesmate features, including creating, updating, deleting, and getting activities, companies, and deals. 

  On this page, you'll find a list of operations the Salesmate node supports and links to more resources.

  /// note | Credentials
  Refer to [Salesmate credentials](/integrations/builtin/credentials/salesmate.md) for guidance on setting up authentication. 
  ///

  ## Operations

  * Activity
      * Create an activity
      * Delete an activity
      * Get an activity
      * Get all companies
      * Update an activity
  * Company
      * Create a company
      * Delete a company
      * Get a company
      * Get all companies
      * Update a company
  * Deal
      * Create a deal
      * Delete a deal
      * Get a deal
      * Get all deals
      * Update a deal

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'salesmate') ]]

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"d27f7f64-869a-43cd-89ca-f74092a56106","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"18ce212111e35f2082156b94cff7ad1bb0df8dcb4979e63c2cd4763b45ec1468"}}


node_type: n8n-nodes-base.SeaTable
name: SeaTable
display_name: SeaTable
description: Consume the SeaTable API
category: input
icon: file:seaTable.svg
code_hash: 2838fa6931fb12f6c56a751f7251d2eed63f2f2160f055204f3a37ef31dd043a
documentation_url: https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.seatabletrigger
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 09:18:26
updated_at: 2025-06-08 09:18:26
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.SeaTable = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const GenericFunctions_1 = require("./GenericFunctions");
  const RowDescription_1 = require("./RowDescription");
  class SeaTable {
      constructor() {
          this.description = {
              displayName: 'SeaTable',
              name: 'seaTable',
              icon: 'file:seaTable.svg',
              group: ['input'],
              version: 1,
              subtitle: '={{$parameter["resource"] + ": " + $parameter["operation"]}}',
              description: 'Consume the SeaTable API',
              defaults: {
                  name: 'SeaTable',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'seaTableApi',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Row',
                              value: 'row',
                          },
                      ],
                      default: 'row',
                  },
                  ...RowDescription_1.rowOperations,
                  ...RowDescription_1.rowFields,
              ],
          };
          this.methods = {
              loadOptions: {
                  async getTableNames() {
                      const returnData = [];
                      const { metadata: { tables }, } = await GenericFunctions_1.seaTableApiRequest.call(this, {}, 'GET', '/dtable-server/api/v1/dtables/{{dtable_uuid}}/metadata');
                      for (const table of tables) {
                          returnData.push({
                              name: table.name,
                              value: table.name,
                          });
                      }
                      return returnData;
                  },
                  async getTableIds() {
                      const returnData = [];
                      const { metadata: { tables }, } = await GenericFunctions_1.seaTableApiRequest.call(this, {}, 'GET', '/dtable-server/api/v1/dtables/{{dtable_uuid}}/metadata');
                      for (const table of tables) {
                          returnData.push({
                              name: table.name,
                              value: table._id,
                          });
                      }
                      return returnData;
                  },
                  async getTableUpdateAbleColumns() {
                      const tableName = this.getNodeParameter('tableName');
                      const columns = await GenericFunctions_1.getTableColumns.call(this, tableName);
                      return columns
                          .filter((column) => column.editable)
                          .map((column) => ({ name: column.name, value: column.name }));
                  },
                  async getAllSortableColumns() {
                      const tableName = this.getNodeParameter('tableName');
                      const columns = await GenericFunctions_1.getTableColumns.call(this, tableName);
                      return columns
                          .filter((column) => !['file', 'image', 'url', 'collaborator', 'long-text'].includes(column.type))
                          .map((column) => ({ name: column.name, value: column.name }));
                  },
                  async getViews() {
                      const tableName = this.getNodeParameter('tableName');
                      const views = await GenericFunctions_1.getTableViews.call(this, tableName);
                      return views.map((view) => ({ name: view.name, value: view.name }));
                  },
              },
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          let responseData;
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          const body = {};
          const qs = {};
          const ctx = {};
          if (resource === 'row') {
              if (operation === 'create') {
                  const tableName = this.getNodeParameter('tableName', 0);
                  const tableColumns = await GenericFunctions_1.getTableColumns.call(this, tableName);
                  body.table_name = tableName;
                  const fieldsToSend = this.getNodeParameter('fieldsToSend', 0);
                  let rowInput = {};
                  for (let i = 0; i < items.length; i++) {
                      rowInput = {};
                      try {
                          if (fieldsToSend === 'autoMapInputData') {
                              const incomingKeys = Object.keys(items[i].json);
                              const inputDataToIgnore = (0, GenericFunctions_1.split)(this.getNodeParameter('inputsToIgnore', i, ''));
                              for (const key of incomingKeys) {
                                  if (inputDataToIgnore.includes(key))
                                      continue;
                                  rowInput[key] = items[i].json[key];
                              }
                          }
                          else {
                              const columns = this.getNodeParameter('columnsUi.columnValues', i, []);
                              for (const column of columns) {
                                  rowInput[column.columnName] = column.columnValue;
                              }
                          }
                          body.row = (0, GenericFunctions_1.rowExport)(rowInput, (0, GenericFunctions_1.updateAble)(tableColumns));
                          responseData = await GenericFunctions_1.seaTableApiRequest.call(this, ctx, 'POST', '/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/', body);
                          const { _id: insertId } = responseData;
                          if (insertId === undefined) {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'SeaTable: No identity after appending row.', { itemIndex: i });
                          }
                          const newRowInsertData = (0, GenericFunctions_1.rowMapKeyToName)(responseData, tableColumns);
                          qs.table_name = tableName;
                          qs.convert = true;
                          const newRow = await GenericFunctions_1.seaTableApiRequest.call(this, ctx, 'GET', `/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/${encodeURIComponent(insertId)}/`, body, qs);
                          if (newRow._id === undefined) {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'SeaTable: No identity for appended row.', { itemIndex: i });
                          }
                          const row = (0, GenericFunctions_1.rowFormatColumns)({ ...newRowInsertData, ...newRow }, tableColumns.map(({ name }) => name).concat(['_id', '_ctime', '_mtime']));
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(row), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionErrorData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              else if (operation === 'get') {
                  for (let i = 0; i < items.length; i++) {
                      try {
                          const tableId = this.getNodeParameter('tableId', 0);
                          const rowId = this.getNodeParameter('rowId', i);
                          const response = (await GenericFunctions_1.seaTableApiRequest.call(this, ctx, 'GET', `/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/${rowId}`, {}, { table_id: tableId, convert: true }));
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(response), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionErrorData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              else if (operation === 'getAll') {
                  const tableName = this.getNodeParameter('tableName', 0);
                  const tableColumns = await GenericFunctions_1.getTableColumns.call(this, tableName);
                  for (let i = 0; i < items.length; i++) {
                      try {
                          const endpoint = '/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/';
                          qs.table_name = tableName;
                          const filters = this.getNodeParameter('filters', i);
                          const options = this.getNodeParameter('options', i);
                          const returnAll = this.getNodeParameter('returnAll', 0);
                          Object.assign(qs, filters, options);
                          if (qs.convert_link_id === false) {
                              delete qs.convert_link_id;
                          }
                          if (returnAll) {
                              responseData = await GenericFunctions_1.setableApiRequestAllItems.call(this, ctx, 'rows', 'GET', endpoint, body, qs);
                          }
                          else {
                              qs.limit = this.getNodeParameter('limit', 0);
                              responseData = await GenericFunctions_1.seaTableApiRequest.call(this, ctx, 'GET', endpoint, body, qs);
                              responseData = responseData.rows;
                          }
                          const rows = responseData.map((row) => (0, GenericFunctions_1.rowFormatColumns)({ ...row }, tableColumns.map(({ name }) => name).concat(['_id', '_ctime', '_mtime'])));
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(rows), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionErrorData);
                          }
                          throw error;
                      }
                  }
              }
              else if (operation === 'delete') {
                  for (let i = 0; i < items.length; i++) {
                      try {
                          const tableName = this.getNodeParameter('tableName', 0);
                          const rowId = this.getNodeParameter('rowId', i);
                          const requestBody = {
                              table_name: tableName,
                              row_id: rowId,
                          };
                          const response = (await GenericFunctions_1.seaTableApiRequest.call(this, ctx, 'DELETE', '/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/', requestBody, qs));
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(response), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionErrorData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              else if (operation === 'update') {
                  const tableName = this.getNodeParameter('tableName', 0);
                  const tableColumns = await GenericFunctions_1.getTableColumns.call(this, tableName);
                  body.table_name = tableName;
                  const fieldsToSend = this.getNodeParameter('fieldsToSend', 0);
                  let rowInput = {};
                  for (let i = 0; i < items.length; i++) {
                      const rowId = this.getNodeParameter('rowId', i);
                      rowInput = {};
                      try {
                          if (fieldsToSend === 'autoMapInputData') {
                              const incomingKeys = Object.keys(items[i].json);
                              const inputDataToIgnore = (0, GenericFunctions_1.split)(this.getNodeParameter('inputsToIgnore', i, ''));
                              for (const key of incomingKeys) {
                                  if (inputDataToIgnore.includes(key))
                                      continue;
                                  rowInput[key] = items[i].json[key];
                              }
                          }
                          else {
                              const columns = this.getNodeParameter('columnsUi.columnValues', i, []);
                              for (const column of columns) {
                                  rowInput[column.columnName] = column.columnValue;
                              }
                          }
                          body.row = (0, GenericFunctions_1.rowExport)(rowInput, (0, GenericFunctions_1.updateAble)(tableColumns));
                          body.table_name = tableName;
                          body.row_id = rowId;
                          responseData = await GenericFunctions_1.seaTableApiRequest.call(this, ctx, 'PUT', '/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/', body);
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ _id: rowId, ...responseData }), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionErrorData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              else {
                  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`);
              }
          }
          return [returnData];
      }
  }
  exports.SeaTable = SeaTable;
  //# sourceMappingURL=SeaTable.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: SeaTable Trigger node documentation
  description: Learn how to use the SeaTable Trigger node in n8n. Follow technical documentation to integrate SeaTable Trigger node into your workflows.
  contentType: [integration, reference]
  ---

  # SeaTable Trigger node

  [SeaTable](https://seatable.io/en){:target=_blank .external-link} is a collaborative database application with a spreadsheet interface.

  /// note | Credentials
  You can find authentication information for this node [here](/integrations/builtin/credentials/seatable.md).
  ///

  ///  note  | Examples and templates
  For usage examples and templates to help you get started, refer to n8n's [SeaTable Trigger integrations](https://n8n.io/integrations/seatable-trigger/){:target=_blank .external-link} page.
  ///

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"b98d0857-788d-46a8-aa48-fe2555d6a1f9","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"e283d9d5a6684943cc748d7592f001b8f9e5d4f888abe69ce2faf9cdcdb840c5"}}


node_type: n8n-nodes-base.Segment
name: Segment
display_name: Segment
description: Consume Segment API
category: output
icon: file:segment.svg
code_hash: 9fc9d8949d7a2d9b8ae94a10b699705756e1f9f2cb2e6a0feeff301b5108b19d
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.segment
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 09:18:26
updated_at: 2025-06-08 09:18:26
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Segment = void 0;
  const GenericFunctions_1 = require("./GenericFunctions");
  const GroupDescription_1 = require("./GroupDescription");
  const IdentifyDescription_1 = require("./IdentifyDescription");
  const TrackDescription_1 = require("./TrackDescription");
  const uuid_1 = require("uuid");
  class Segment {
      constructor() {
          this.description = {
              displayName: 'Segment',
              name: 'segment',
              icon: 'file:segment.svg',
              group: ['output'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ":" + $parameter["resource"]}}',
              description: 'Consume Segment API',
              defaults: {
                  name: 'Segment',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'segmentApi',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Group',
                              value: 'group',
                              description: 'Group lets you associate an identified user with a group',
                          },
                          {
                              name: 'Identify',
                              value: 'identify',
                              description: 'Identify lets you tie a user to their actions',
                          },
                          {
                              name: 'Track',
                              value: 'track',
                              description: 'Track lets you record events',
                          },
                      ],
                      default: 'identify',
                  },
                  ...GroupDescription_1.groupOperations,
                  ...GroupDescription_1.groupFields,
                  ...IdentifyDescription_1.identifyOperations,
                  ...TrackDescription_1.trackOperations,
                  ...IdentifyDescription_1.identifyFields,
                  ...TrackDescription_1.trackFields,
              ],
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          const length = items.length;
          let responseData;
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          for (let i = 0; i < length; i++) {
              try {
                  if (resource === 'group') {
                      if (operation === 'add') {
                          const userId = this.getNodeParameter('userId', i);
                          const groupId = this.getNodeParameter('groupId', i);
                          const traits = this.getNodeParameter('traits', i)
                              .traitsUi;
                          const context = this.getNodeParameter('context', i)
                              .contextUi;
                          const integrations = this.getNodeParameter('integrations', i)
                              .integrationsUi;
                          const body = {
                              groupId,
                              traits: {
                                  company: {},
                                  address: {},
                              },
                              context: {
                                  app: {},
                                  campaign: {},
                                  device: {},
                              },
                              integrations: {},
                          };
                          if (userId) {
                              body.userId = userId;
                          }
                          else {
                              body.anonymousId = (0, uuid_1.v4)();
                          }
                          if (traits) {
                              if (traits && traits.length !== 0) {
                                  for (const trait of traits) {
                                      body.traits[trait.key] = trait.value;
                                  }
                              }
                          }
                          if (context) {
                              if (context.active) {
                                  body.context.active = context.active;
                              }
                              if (context.ip) {
                                  body.context.ip = context.ip;
                              }
                              if (context.locate) {
                                  body.context.locate = context.locate;
                              }
                              if (context.page) {
                                  body.context.page = context.page;
                              }
                              if (context.timezone) {
                                  body.context.timezone = context.timezone;
                              }
                              if (context.timezone) {
                                  body.context.timezone = context.timezone;
                              }
                              if (context.app) {
                                  const app = context.app.appUi;
                                  if (app) {
                                      if (app.name) {
                                          body.context.app.name = app.name;
                                      }
                                      if (app.version) {
                                          body.context.app.version = app.version;
                                      }
                                      if (app.build) {
                                          body.context.app.build = app.build;
                                      }
                                  }
                              }
                              if (context.campaign) {
                                  const campaign = context.campaign.campaignUi;
                                  if (campaign) {
                                      if (campaign.name) {
                                          body.context.campaign.name = campaign.name;
                                      }
                                      if (campaign.source) {
                                          body.context.campaign.source = campaign.source;
                                      }
                                      if (campaign.medium) {
                                          body.context.campaign.medium = campaign.medium;
                                      }
                                      if (campaign.term) {
                                          body.context.campaign.term = campaign.term;
                                      }
                                      if (campaign.content) {
                                          body.context.campaign.content = campaign.content;
                                      }
                                  }
                              }
                              if (context.device) {
                                  const device = context.device.deviceUi;
                                  if (device) {
                                      if (device.id) {
                                          body.context.device.id = device.id;
                                      }
                                      if (device.manufacturer) {
                                          body.context.device.manufacturer = device.manufacturer;
                                      }
                                      if (device.model) {
                                          body.context.device.model = device.model;
                                      }
                                      if (device.type) {
                                          body.context.device.type = device.type;
                                      }
                                      if (device.version) {
                                          body.context.device.version = device.version;
                                      }
                                  }
                              }
                          }
                          if (integrations) {
                              if (integrations.all) {
                                  body.integrations.all = integrations.all;
                              }
                              if (integrations.salesforce) {
                                  body.integrations.salesforce = integrations.salesforce;
                              }
                          }
                          responseData = await GenericFunctions_1.segmentApiRequest.call(this, 'POST', '/group', body);
                      }
                  }
                  if (resource === 'identify') {
                      if (operation === 'create') {
                          const userId = this.getNodeParameter('userId', i);
                          const context = this.getNodeParameter('context', i)
                              .contextUi;
                          const traits = this.getNodeParameter('traits', i)
                              .traitsUi;
                          const integrations = this.getNodeParameter('integrations', i)
                              .integrationsUi;
                          const body = {
                              context: {
                                  app: {},
                                  campaign: {},
                                  device: {},
                              },
                              traits: {},
                              integrations: {},
                          };
                          if (userId) {
                              body.userId = userId;
                          }
                          else {
                              body.anonymousId = (0, uuid_1.v4)();
                          }
                          if (context) {
                              if (context.active) {
                                  body.context.active = context.active;
                              }
                              if (context.ip) {
                                  body.context.ip = context.ip;
                              }
                              if (context.locate) {
                                  body.context.locate = context.locate;
                              }
                              if (context.page) {
                                  body.context.page = context.page;
                              }
                              if (context.timezone) {
                                  body.context.timezone = context.timezone;
                              }
                              if (context.timezone) {
                                  body.context.timezone = context.timezone;
                              }
                              if (context.app) {
                                  const app = context.app.appUi;
                                  if (app) {
                                      if (app.name) {
                                          body.context.app.name = app.name;
                                      }
                                      if (app.version) {
                                          body.context.app.version = app.version;
                                      }
                                      if (app.build) {
                                          body.context.app.build = app.build;
                                      }
                                  }
                              }
                              if (context.campaign) {
                                  const campaign = context.campaign.campaignUi;
                                  if (campaign) {
                                      if (campaign.name) {
                                          body.context.campaign.name = campaign.name;
                                      }
                                      if (campaign.source) {
                                          body.context.campaign.source = campaign.source;
                                      }
                                      if (campaign.medium) {
                                          body.context.campaign.medium = campaign.medium;
                                      }
                                      if (campaign.term) {
                                          body.context.campaign.term = campaign.term;
                                      }
                                      if (campaign.content) {
                                          body.context.campaign.content = campaign.content;
                                      }
                                  }
                              }
                              if (context.device) {
                                  const device = context.device.deviceUi;
                                  if (device) {
                                      if (device.id) {
                                          body.context.device.id = device.id;
                                      }
                                      if (device.manufacturer) {
                                          body.context.device.manufacturer = device.manufacturer;
                                      }
                                      if (device.model) {
                                          body.context.device.model = device.model;
                                      }
                                      if (device.type) {
                                          body.context.device.type = device.type;
                                      }
                                      if (device.version) {
                                          body.context.device.version = device.version;
                                      }
                                  }
                              }
                          }
                          if (integrations) {
                              if (integrations.all) {
                                  body.integrations.all = integrations.all;
                              }
                              if (integrations.salesforce) {
                                  body.integrations.salesforce = integrations.salesforce;
                              }
                          }
                          if (traits) {
                              if (traits && traits.length !== 0) {
                                  for (const trait of traits) {
                                      body.traits[trait.key] = trait.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.segmentApiRequest.call(this, 'POST', '/identify', body);
                      }
                  }
                  if (resource === 'track') {
                      if (operation === 'event') {
                          const userId = this.getNodeParameter('userId', i);
                          const event = this.getNodeParameter('event', i);
                          const context = this.getNodeParameter('context', i)
                              .contextUi;
                          const integrations = this.getNodeParameter('integrations', i)
                              .integrationsUi;
                          const properties = this.getNodeParameter('properties', i)
                              .propertiesUi;
                          const body = {
                              event,
                              traits: {},
                              context: {
                                  app: {},
                                  campaign: {},
                                  device: {},
                              },
                              integrations: {},
                              properties: {},
                          };
                          if (userId) {
                              body.userId = userId;
                          }
                          else {
                              body.anonymousId = (0, uuid_1.v4)();
                          }
                          if (context) {
                              if (context.active) {
                                  body.context.active = context.active;
                              }
                              if (context.ip) {
                                  body.context.ip = context.ip;
                              }
                              if (context.locate) {
                                  body.context.locate = context.locate;
                              }
                              if (context.page) {
                                  body.context.page = context.page;
                              }
                              if (context.timezone) {
                                  body.context.timezone = context.timezone;
                              }
                              if (context.timezone) {
                                  body.context.timezone = context.timezone;
                              }
                              if (context.app) {
                                  const app = context.app.appUi;
                                  if (app) {
                                      if (app.name) {
                                          body.context.app.name = app.name;
                                      }
                                      if (app.version) {
                                          body.context.app.version = app.version;
                                      }
                                      if (app.build) {
                                          body.context.app.build = app.build;
                                      }
                                  }
                              }
                              if (context.campaign) {
                                  const campaign = context.campaign.campaignUi;
                                  if (campaign) {
                                      if (campaign.name) {
                                          body.context.campaign.name = campaign.name;
                                      }
                                      if (campaign.source) {
                                          body.context.campaign.source = campaign.source;
                                      }
                                      if (campaign.medium) {
                                          body.context.campaign.medium = campaign.medium;
                                      }
                                      if (campaign.term) {
                                          body.context.campaign.term = campaign.term;
                                      }
                                      if (campaign.content) {
                                          body.context.campaign.content = campaign.content;
                                      }
                                  }
                              }
                              if (context.device) {
                                  const device = context.device.deviceUi;
                                  if (device) {
                                      if (device.id) {
                                          body.context.device.id = device.id;
                                      }
                                      if (device.manufacturer) {
                                          body.context.device.manufacturer = device.manufacturer;
                                      }
                                      if (device.model) {
                                          body.context.device.model = device.model;
                                      }
                                      if (device.type) {
                                          body.context.device.type = device.type;
                                      }
                                      if (device.version) {
                                          body.context.device.version = device.version;
                                      }
                                  }
                              }
                          }
                          if (integrations) {
                              if (integrations.all) {
                                  body.integrations.all = integrations.all;
                              }
                              if (integrations.salesforce) {
                                  body.integrations.salesforce = integrations.salesforce;
                              }
                          }
                          if (properties) {
                              if (properties && properties.length !== 0) {
                                  for (const property of properties) {
                                      body.properties[property.key] = property.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.segmentApiRequest.call(this, 'POST', '/track', body);
                      }
                      if (operation === 'page') {
                          const userId = this.getNodeParameter('userId', i);
                          const name = this.getNodeParameter('name', i);
                          const context = this.getNodeParameter('context', i)
                              .contextUi;
                          const integrations = this.getNodeParameter('integrations', i)
                              .integrationsUi;
                          const properties = this.getNodeParameter('properties', i)
                              .propertiesUi;
                          const body = {
                              name,
                              traits: {},
                              context: {
                                  app: {},
                                  campaign: {},
                                  device: {},
                              },
                              integrations: {},
                              properties: {},
                          };
                          if (userId) {
                              body.userId = userId;
                          }
                          else {
                              body.anonymousId = (0, uuid_1.v4)();
                          }
                          if (context) {
                              if (context.active) {
                                  body.context.active = context.active;
                              }
                              if (context.ip) {
                                  body.context.ip = context.ip;
                              }
                              if (context.locate) {
                                  body.context.locate = context.locate;
                              }
                              if (context.page) {
                                  body.context.page = context.page;
                              }
                              if (context.timezone) {
                                  body.context.timezone = context.timezone;
                              }
                              if (context.timezone) {
                                  body.context.timezone = context.timezone;
                              }
                              if (context.app) {
                                  const app = context.app.appUi;
                                  if (app) {
                                      if (app.name) {
                                          body.context.app.name = app.name;
                                      }
                                      if (app.version) {
                                          body.context.app.version = app.version;
                                      }
                                      if (app.build) {
                                          body.context.app.build = app.build;
                                      }
                                  }
                              }
                              if (context.campaign) {
                                  const campaign = context.campaign.campaignUi;
                                  if (campaign) {
                                      if (campaign.name) {
                                          body.context.campaign.name = campaign.name;
                                      }
                                      if (campaign.source) {
                                          body.context.campaign.source = campaign.source;
                                      }
                                      if (campaign.medium) {
                                          body.context.campaign.medium = campaign.medium;
                                      }
                                      if (campaign.term) {
                                          body.context.campaign.term = campaign.term;
                                      }
                                      if (campaign.content) {
                                          body.context.campaign.content = campaign.content;
                                      }
                                  }
                              }
                              if (context.device) {
                                  const device = context.device.deviceUi;
                                  if (device) {
                                      if (device.id) {
                                          body.context.device.id = device.id;
                                      }
                                      if (device.manufacturer) {
                                          body.context.device.manufacturer = device.manufacturer;
                                      }
                                      if (device.model) {
                                          body.context.device.model = device.model;
                                      }
                                      if (device.type) {
                                          body.context.device.type = device.type;
                                      }
                                      if (device.version) {
                                          body.context.device.version = device.version;
                                      }
                                  }
                              }
                          }
                          if (integrations) {
                              if (integrations.all) {
                                  body.integrations.all = integrations.all;
                              }
                              if (integrations.salesforce) {
                                  body.integrations.salesforce = integrations.salesforce;
                              }
                          }
                          if (properties) {
                              if (properties && properties.length !== 0) {
                                  for (const property of properties) {
                                      body.properties[property.key] = property.value;
                                  }
                              }
                          }
                          responseData = await GenericFunctions_1.segmentApiRequest.call(this, 'POST', '/page', body);
                      }
                  }
              }
              catch (error) {
                  if (this.continueOnFail()) {
                      returnData.push({ error: error.message });
                      continue;
                  }
                  throw error;
              }
              if (Array.isArray(responseData)) {
                  returnData.push.apply(returnData, responseData);
              }
              else {
                  returnData.push(responseData);
              }
          }
          return [this.helpers.returnJsonArray(returnData)];
      }
  }
  exports.Segment = Segment;
  //# sourceMappingURL=Segment.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Segment node documentation
  description: Learn how to use the Segment node in n8n. Follow technical documentation to integrate Segment node into your workflows.
  contentType: [integration, reference]
  ---

  # Segment node

  Use the Segment node to automate work in Segment, and integrate Segment with other applications. n8n has built-in support for a wide range of Segment features, including adding users to groups, creating identities, and tracking activities. 

  On this page, you'll find a list of operations the Segment node supports and links to more resources.

  /// note | Credentials
  Refer to [Segment credentials](/integrations/builtin/credentials/segment.md) for guidance on setting up authentication. 
  ///

  ## Operations

  * Group
      * Add a user to a group
  * Identify
      * Create an identity
  * Track
      * Record the actions your users perform. Every action triggers an event, which can also have associated properties.
      * Record page views on your website, along with optional extra information about the page being viewed.

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'segment') ]]

  --8<-- "_snippets/integrations/builtin/app-nodes/operation-not-supported.md"

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"20557081-bbde-4288-aa83-97c9f7fd0c1c","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"ad25b8f4e8917e1f40147e970204e447ddb14ac5ed81654cb28385ab864c52ea"}}


node_type: n8n-nodes-base.SecurityScorecard
name: SecurityScorecard
display_name: SecurityScorecard
description: Consume SecurityScorecard API
category: transform
icon: file:securityScorecard.svg
code_hash: 126925cdb415faf27b54c0587590eb72f3a0a7a7be4adb9f5ffbc6121152ca14
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.securityscorecard
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 09:18:26
updated_at: 2025-06-08 09:18:26
source_code:
  "use strict";
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.SecurityScorecard = void 0;
  const CompanyDescription_1 = require("./descriptions/CompanyDescription");
  const IndustryDescription_1 = require("./descriptions/IndustryDescription");
  const InviteDescription_1 = require("./descriptions/InviteDescription");
  const PortfolioDescription_1 = require("./descriptions/PortfolioDescription");
  const PortfolioCompanyDescription_1 = require("./descriptions/PortfolioCompanyDescription");
  const ReportDescription_1 = require("./descriptions/ReportDescription");
  const GenericFunctions_1 = require("./GenericFunctions");
  const moment_1 = __importDefault(require("moment"));
  class SecurityScorecard {
      constructor() {
          this.description = {
              displayName: 'SecurityScorecard',
              name: 'securityScorecard',
              icon: 'file:securityScorecard.svg',
              group: ['transform'],
              subtitle: '={{$parameter["operation"]}} : {{$parameter["resource"]}}',
              version: 1,
              description: 'Consume SecurityScorecard API',
              defaults: {
                  name: 'SecurityScorecard',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'securityScorecardApi',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      required: true,
                      options: [
                          {
                              name: 'Company',
                              value: 'company',
                          },
                          {
                              name: 'Industry',
                              value: 'industry',
                          },
                          {
                              name: 'Invite',
                              value: 'invite',
                          },
                          {
                              name: 'Portfolio',
                              value: 'portfolio',
                          },
                          {
                              name: 'Portfolio Company',
                              value: 'portfolioCompany',
                          },
                          {
                              name: 'Report',
                              value: 'report',
                          },
                      ],
                      default: 'company',
                  },
                  ...CompanyDescription_1.companyOperations,
                  ...CompanyDescription_1.companyFields,
                  ...IndustryDescription_1.industryOperations,
                  ...IndustryDescription_1.industryFields,
                  ...InviteDescription_1.inviteOperations,
                  ...InviteDescription_1.inviteFields,
                  ...PortfolioDescription_1.portfolioOperations,
                  ...PortfolioDescription_1.portfolioFields,
                  ...PortfolioCompanyDescription_1.portfolioCompanyOperations,
                  ...PortfolioCompanyDescription_1.portfolioCompanyFields,
                  ...ReportDescription_1.reportOperations,
                  ...ReportDescription_1.reportFields,
              ],
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          let responseData;
          const length = items.length;
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          for (let i = 0; i < length; i++) {
              if (resource === 'portfolio') {
                  if (operation === 'create') {
                      const name = this.getNodeParameter('name', i);
                      const description = this.getNodeParameter('description', i);
                      const privacy = this.getNodeParameter('privacy', i);
                      const body = {
                          name,
                          description,
                          privacy,
                      };
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'POST', 'portfolios', body);
                      returnData.push(responseData);
                  }
                  if (operation === 'delete') {
                      const portfolioId = this.getNodeParameter('portfolioId', i);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'DELETE', `portfolios/${portfolioId}`);
                      returnData.push({ success: true });
                  }
                  if (operation === 'update') {
                      const portfolioId = this.getNodeParameter('portfolioId', i);
                      const name = this.getNodeParameter('name', i);
                      const description = this.getNodeParameter('description', i);
                      const privacy = this.getNodeParameter('privacy', i);
                      const body = {
                          name,
                          description,
                          privacy,
                      };
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'PUT', `portfolios/${portfolioId}`, body);
                      returnData.push(responseData);
                  }
                  if (operation === 'getAll') {
                      const returnAll = this.getNodeParameter('returnAll', 0);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', 'portfolios');
                      responseData = responseData.entries;
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', 0);
                          responseData = responseData.splice(0, limit);
                      }
                      returnData.push.apply(returnData, responseData);
                  }
              }
              if (resource === 'portfolioCompany') {
                  if (operation === 'add') {
                      const portfolioId = this.getNodeParameter('portfolioId', i);
                      const domain = this.getNodeParameter('domain', i);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'PUT', `portfolios/${portfolioId}/companies/${domain}`);
                      returnData.push(responseData);
                  }
                  if (operation === 'remove') {
                      const portfolioId = this.getNodeParameter('portfolioId', i);
                      const domain = this.getNodeParameter('domain', i);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'DELETE', `portfolios/${portfolioId}/companies/${domain}`);
                      returnData.push({ success: true });
                  }
                  if (operation === 'getAll') {
                      const returnAll = this.getNodeParameter('returnAll', 0);
                      const portfolioId = this.getNodeParameter('portfolioId', i);
                      const filterParams = this.getNodeParameter('filters', i);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', `portfolios/${portfolioId}/companies`, {}, filterParams);
                      responseData = responseData.entries;
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', 0);
                          responseData = responseData.splice(0, limit);
                      }
                      returnData.push.apply(returnData, responseData);
                  }
              }
              if (resource === 'report') {
                  if (operation === 'download') {
                      const reportUrl = this.getNodeParameter('url', i);
                      const response = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', '', {}, {}, reportUrl, {
                          encoding: null,
                          resolveWithFullResponse: true,
                      });
                      let mimeType;
                      if (response.headers['content-type']) {
                          mimeType = response.headers['content-type'];
                      }
                      const newItem = {
                          json: items[i].json,
                          binary: {},
                      };
                      if (items[i].binary !== undefined && newItem.binary) {
                          Object.assign(newItem.binary, items[i].binary);
                      }
                      items[i] = newItem;
                      const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
                      const fileName = reportUrl.split('/').pop();
                      const data = Buffer.from(response.body, 'utf8');
                      items[i].binary[dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data, fileName, mimeType);
                  }
                  if (operation === 'generate') {
                      const reportType = this.getNodeParameter('report', i);
                      let body = {};
                      if (reportType !== 'portfolio') {
                          body.scorecard_identifier = this.getNodeParameter('scorecardIdentifier', i);
                      }
                      else {
                          body.portfolio_id = this.getNodeParameter('portfolioId', i);
                      }
                      if (reportType === 'events-json') {
                          body.date = this.getNodeParameter('date', i);
                      }
                      if (['issues', 'portfolio'].indexOf(reportType) > -1) {
                          body.format = this.getNodeParameter('options.format', i) || 'pdf';
                      }
                      if (['detailed', 'summary'].indexOf(reportType) > -1) {
                          body.branding = this.getNodeParameter('branding', i);
                      }
                      if (['events-json', 'full-scorecard-json'].indexOf(reportType) > -1) {
                          body = { params: body };
                      }
                      if (reportType === 'scorecard-footprint') {
                          const options = this.getNodeParameter('options', i);
                          Object.assign(body, options);
                      }
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'POST', `reports/${reportType}`, body);
                      returnData.push(responseData);
                  }
                  if (operation === 'getAll') {
                      const returnAll = this.getNodeParameter('returnAll', 0);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', 'reports/recent');
                      responseData = responseData.entries;
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', i);
                          responseData = responseData.splice(0, limit);
                      }
                      returnData.push.apply(returnData, responseData);
                  }
              }
              if (resource === 'invite') {
                  if (operation === 'create') {
                      const body = {
                          email: this.getNodeParameter('email', i),
                          first_name: this.getNodeParameter('firstName', i),
                          last_name: this.getNodeParameter('lastName', i),
                          message: this.getNodeParameter('message', i),
                      };
                      const additionalFields = this.getNodeParameter('additionalFields', i);
                      Object.assign(body, additionalFields);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'POST', 'invitations', body);
                      returnData.push(responseData);
                  }
              }
              if (resource === 'industry') {
                  if (operation === 'getScore') {
                      const industry = this.getNodeParameter('industry', i);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', `industries/${industry}/score`);
                      returnData.push(responseData);
                  }
                  if (operation === 'getFactor') {
                      const simple = this.getNodeParameter('simple', 0);
                      const returnAll = this.getNodeParameter('returnAll', 0);
                      const industry = this.getNodeParameter('industry', i);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', `industries/${industry}/history/factors`);
                      responseData = responseData.entries;
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', i);
                          responseData = responseData.splice(0, limit);
                      }
                      if (simple) {
                          responseData = (0, GenericFunctions_1.simplify)(responseData);
                      }
                      returnData.push.apply(returnData, responseData);
                  }
                  if (operation === 'getFactorHistorical') {
                      const simple = this.getNodeParameter('simple', 0);
                      const returnAll = this.getNodeParameter('returnAll', i);
                      const industry = this.getNodeParameter('industry', i);
                      const options = this.getNodeParameter('options', i);
                      if (options.from) {
                          options.from = (0, moment_1.default)(options.from).format('YYYY-MM-DD');
                      }
                      if (options.to) {
                          options.to = (0, moment_1.default)(options.to).format('YYYY-MM-DD');
                      }
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', `industries/${industry}/history/factors`, {}, options);
                      responseData = responseData.entries;
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', i);
                          responseData = responseData.splice(0, limit);
                      }
                      if (simple) {
                          responseData = (0, GenericFunctions_1.simplify)(responseData);
                      }
                      returnData.push.apply(returnData, responseData);
                  }
              }
              if (resource === 'company') {
                  if (operation === 'getScorecard') {
                      const scorecardIdentifier = this.getNodeParameter('scorecardIdentifier', i);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', `companies/${scorecardIdentifier}`);
                      returnData.push(responseData);
                  }
                  if (operation === 'getFactor') {
                      const returnAll = this.getNodeParameter('returnAll', i);
                      const scorecardIdentifier = this.getNodeParameter('scorecardIdentifier', i);
                      const filterParams = this.getNodeParameter('filters', i);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', `companies/${scorecardIdentifier}/factors`, {}, filterParams);
                      responseData = responseData.entries;
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', i);
                          responseData = responseData.splice(0, limit);
                      }
                      returnData.push.apply(returnData, responseData);
                  }
                  if (operation === 'getFactorHistorical') {
                      const simple = this.getNodeParameter('simple', 0);
                      const returnAll = this.getNodeParameter('returnAll', i);
                      const scorecardIdentifier = this.getNodeParameter('scorecardIdentifier', i);
                      const options = this.getNodeParameter('options', i);
                      if (options.date_from) {
                          options.date_from = (0, moment_1.default)(options.date_from).format('YYYY-MM-DD');
                      }
                      if (options.date_to) {
                          options.date_to = (0, moment_1.default)(options.date_to).format('YYYY-MM-DD');
                      }
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', `companies/${scorecardIdentifier}/history/factors/score`, {}, options);
                      responseData = responseData.entries;
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', i);
                          responseData = responseData.splice(0, limit);
                      }
                      if (simple) {
                          responseData = (0, GenericFunctions_1.simplify)(responseData);
                      }
                      returnData.push.apply(returnData, responseData);
                  }
                  if (operation === 'getHistoricalScore') {
                      const simple = this.getNodeParameter('simple', 0);
                      const returnAll = this.getNodeParameter('returnAll', i);
                      const scorecardIdentifier = this.getNodeParameter('scorecardIdentifier', i);
                      const options = this.getNodeParameter('options', i);
                      if (options.date_from) {
                          options.from = (0, moment_1.default)(options.date_from).format('YYYY-MM-DD');
                          delete options.date_from;
                      }
                      if (options.date_to) {
                          options.to = (0, moment_1.default)(options.date_to).format('YYYY-MM-DD');
                          delete options.date_to;
                      }
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', `companies/${scorecardIdentifier}/history/factors/score`, {}, options);
                      responseData = responseData.entries;
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', i);
                          responseData = responseData.splice(0, limit);
                      }
                      if (simple) {
                          responseData = (0, GenericFunctions_1.simplify)(responseData);
                      }
                      returnData.push.apply(returnData, responseData);
                  }
                  if (operation === 'getScorePlan') {
                      const returnAll = this.getNodeParameter('returnAll', i);
                      const scorecardIdentifier = this.getNodeParameter('scorecardIdentifier', i);
                      const targetScore = this.getNodeParameter('score', i);
                      responseData = await GenericFunctions_1.scorecardApiRequest.call(this, 'GET', `companies/${scorecardIdentifier}/score-plans/by-target/${targetScore}`);
                      responseData = responseData.entries;
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', i);
                          responseData = responseData.splice(0, limit);
                      }
                      returnData.push.apply(returnData, responseData);
                  }
              }
          }
          if (resource === 'report' && operation === 'download') {
              return [items];
          }
          return [this.helpers.returnJsonArray(returnData)];
      }
  }
  exports.SecurityScorecard = SecurityScorecard;
  //# sourceMappingURL=SecurityScorecard.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: SecurityScorecard node documentation
  description: Learn how to use the SecurityScorecard node in n8n. Follow technical documentation to integrate SecurityScorecard node into your workflows.
  contentType: [integration, reference]
  ---

  # SecurityScorecard node

  Use the SecurityScorecard node to automate work in SecurityScorecard, and integrate SecurityScorecard with other applications. n8n has built-in support for a wide range of SecurityScorecard features, including creating, updating, deleting, and getting portfolio, as well as getting a company's data.

  On this page, you'll find a list of operations the SecurityScorecard node supports and links to more resources.

  /// note | Credentials
  Refer to [SecurityScorecard credentials](/integrations/builtin/credentials/securityscorecard.md) for guidance on setting up authentication. 
  ///

  ## Operations

  * Company
      * Get company factor scores and issue counts
      * Get company's historical factor scores
      * Get company's historical scores
      * Get company information and summary of their scorecard
      * Get company's score improvement plan
  * Industry
      * Get Factor Scores
      * Get Historical Factor Scores
      * Get Score
  * Invite
      * Create an invite for a company/user
  * Portfolio
      * Create a portfolio
      * Delete a portfolio
      * Get all portfolios
      * Update a portfolio
  * Portfolio Company
      * Add a company to portfolio
      * Get all companies in a portfolio
      * Remove a company from portfolio
  * Report
      * Download a generated report
      * Generate a report
      * Get list of recently generated report

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'securityscorecard') ]]

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"2c27c02c-1891-4ef9-a1f8-12ac643ec239","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"87cb9dbb231fde13f79cd777b6094b444016a3757987237f6ed4d6180b7d9429"}}


node_type: n8n-nodes-base.SendGrid
name: SendGrid
display_name: SendGrid
description: Consume SendGrid API
category: transform
icon: file:sendGrid.svg
code_hash: c682d47a8e16769aa94a9421671141e4f81eee92760eabbe45af312286758989
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.sendgrid
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 09:18:26
updated_at: 2025-06-08 09:18:26
source_code:
  "use strict";
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.SendGrid = void 0;
  const ListDescription_1 = require("./ListDescription");
  const ContactDescription_1 = require("./ContactDescription");
  const MailDescription_1 = require("./MailDescription");
  const GenericFunctions_1 = require("./GenericFunctions");
  const moment_timezone_1 = __importDefault(require("moment-timezone"));
  class SendGrid {
      constructor() {
          this.description = {
              displayName: 'SendGrid',
              name: 'sendGrid',
              icon: 'file:sendGrid.svg',
              group: ['transform'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ":" + $parameter["resource"]}}',
              description: 'Consume SendGrid API',
              defaults: {
                  name: 'SendGrid',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'sendGridApi',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Contact',
                              value: 'contact',
                          },
                          {
                              name: 'List',
                              value: 'list',
                          },
                          {
                              name: 'Mail',
                              value: 'mail',
                          },
                      ],
                      default: 'list',
                      required: true,
                  },
                  ...ListDescription_1.listOperations,
                  ...ListDescription_1.listFields,
                  ...ContactDescription_1.contactOperations,
                  ...ContactDescription_1.contactFields,
                  ...MailDescription_1.mailOperations,
                  ...MailDescription_1.mailFields,
              ],
          };
          this.methods = {
              loadOptions: {
                  async getCustomFields() {
                      const returnData = [];
                      const { custom_fields } = await GenericFunctions_1.sendGridApiRequest.call(this, '/marketing/field_definitions', 'GET', {}, {});
                      if (custom_fields !== undefined) {
                          for (const customField of custom_fields) {
                              returnData.push({
                                  name: customField.name,
                                  value: customField.id,
                              });
                          }
                      }
                      return returnData;
                  },
                  async getListIds() {
                      const returnData = [];
                      const lists = await GenericFunctions_1.sendGridApiRequestAllItems.call(this, '/marketing/lists', 'GET', 'result', {}, {});
                      for (const list of lists) {
                          returnData.push({
                              name: list.name,
                              value: list.id,
                          });
                      }
                      return returnData;
                  },
                  async getTemplateIds() {
                      const responseData = await GenericFunctions_1.sendGridApiRequest.call(this, '/templates', 'GET', {}, { generations: 'dynamic' });
                      return responseData.templates.map(({ id, name }) => ({
                          name,
                          value: id,
                      }));
                  },
              },
          };
      }
      async execute() {
          const items = this.getInputData();
          const length = items.length;
          const qs = {};
          let responseData;
          const timezone = this.getTimezone();
          const returnData = [];
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          if (resource === 'contact') {
              if (operation === 'getAll') {
                  for (let i = 0; i < length; i++) {
                      try {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const filters = this.getNodeParameter('filters', i);
                          let endpoint = '/marketing/contacts';
                          let method = 'GET';
                          const body = {};
                          if (filters.query && filters.query !== '') {
                              endpoint = '/marketing/contacts/search';
                              method = 'POST';
                              Object.assign(body, { query: filters.query });
                          }
                          responseData = await GenericFunctions_1.sendGridApiRequestAllItems.call(this, endpoint, method, 'result', body, qs);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = responseData.splice(0, limit);
                          }
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              if (operation === 'get') {
                  const by = this.getNodeParameter('by', 0);
                  let endpoint;
                  let method;
                  const body = {};
                  for (let i = 0; i < length; i++) {
                      try {
                          if (by === 'id') {
                              method = 'GET';
                              const contactId = this.getNodeParameter('contactId', i);
                              endpoint = `/marketing/contacts/${contactId}`;
                          }
                          else {
                              const email = this.getNodeParameter('email', i);
                              endpoint = '/marketing/contacts/search';
                              method = 'POST';
                              Object.assign(body, { query: `email LIKE '${email}' ` });
                          }
                          responseData = await GenericFunctions_1.sendGridApiRequest.call(this, endpoint, method, body, qs);
                          responseData = responseData.result || responseData;
                          if (Array.isArray(responseData)) {
                              responseData = responseData[0];
                          }
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              if (operation === 'upsert') {
                  try {
                      const contacts = [];
                      let lists;
                      for (let i = 0; i < length; i++) {
                          const email = this.getNodeParameter('email', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const contact = {
                              email,
                          };
                          if (additionalFields.addressUi) {
                              const addressValues = additionalFields.addressUi
                                  .addressValues;
                              const addressLine1 = addressValues.address1;
                              const addressLine2 = addressValues.address2;
                              if (addressLine2) {
                                  Object.assign(contact, { address_line_2: addressLine2 });
                              }
                              Object.assign(contact, { address_line_1: addressLine1 });
                          }
                          if (additionalFields.city) {
                              const city = additionalFields.city;
                              Object.assign(contact, { city });
                          }
                          if (additionalFields.country) {
                              const country = additionalFields.country;
                              Object.assign(contact, { country });
                          }
                          if (additionalFields.firstName) {
                              const firstName = additionalFields.firstName;
                              Object.assign(contact, { first_name: firstName });
                          }
                          if (additionalFields.lastName) {
                              const lastName = additionalFields.lastName;
                              Object.assign(contact, { last_name: lastName });
                          }
                          if (additionalFields.postalCode) {
                              const postalCode = additionalFields.postalCode;
                              Object.assign(contact, { postal_code: postalCode });
                          }
                          if (additionalFields.stateProvinceRegion) {
                              const stateProvinceRegion = additionalFields.stateProvinceRegion;
                              Object.assign(contact, { state_province_region: stateProvinceRegion });
                          }
                          if (additionalFields.alternateEmails) {
                              const alternateEmails = additionalFields.alternateEmails
                                  .split(',')
                                  .filter((mail) => !!mail);
                              if (alternateEmails.length !== 0) {
                                  Object.assign(contact, { alternate_emails: alternateEmails });
                              }
                          }
                          if (additionalFields.listIdsUi) {
                              const listIdValues = additionalFields.listIdsUi
                                  .listIdValues;
                              const listIds = listIdValues.listIds;
                              lists = listIds;
                          }
                          if (additionalFields.customFieldsUi) {
                              const customFields = additionalFields.customFieldsUi
                                  .customFieldValues;
                              if (customFields) {
                                  const data = customFields.reduce((obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), {});
                                  Object.assign(contact, { custom_fields: data });
                              }
                          }
                          contacts.push(contact);
                      }
                      responseData = await GenericFunctions_1.sendGridApiRequest.call(this, '/marketing/contacts', 'PUT', { list_ids: lists, contacts }, qs);
                      returnData.push(responseData);
                  }
                  catch (error) {
                      if (this.continueOnFail()) {
                          returnData.push({ json: { error: error.message } });
                      }
                      else {
                          throw error;
                      }
                  }
              }
              if (operation === 'delete') {
                  for (let i = 0; i < length; i++) {
                      try {
                          const deleteAll = this.getNodeParameter('deleteAll', i);
                          if (deleteAll) {
                              qs.delete_all_contacts = 'true';
                          }
                          qs.ids = this.getNodeParameter('ids', i).replace(/\s/g, '');
                          responseData = await GenericFunctions_1.sendGridApiRequest.call(this, '/marketing/contacts', 'DELETE', {}, qs);
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
          }
          if (resource === 'list') {
              if (operation === 'getAll') {
                  for (let i = 0; i < length; i++) {
                      try {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          responseData = await GenericFunctions_1.sendGridApiRequestAllItems.call(this, '/marketing/lists', 'GET', 'result', {}, qs);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = responseData.splice(0, limit);
                          }
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              if (operation === 'get') {
                  for (let i = 0; i < length; i++) {
                      try {
                          const listId = this.getNodeParameter('listId', i);
                          qs.contact_sample = this.getNodeParameter('contactSample', i);
                          responseData = await GenericFunctions_1.sendGridApiRequest.call(this, `/marketing/lists/${listId}`, 'GET', {}, qs);
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              if (operation === 'create') {
                  for (let i = 0; i < length; i++) {
                      try {
                          const name = this.getNodeParameter('name', i);
                          responseData = await GenericFunctions_1.sendGridApiRequest.call(this, '/marketing/lists', 'POST', { name }, qs);
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              if (operation === 'delete') {
                  for (let i = 0; i < length; i++) {
                      try {
                          const listId = this.getNodeParameter('listId', i);
                          qs.delete_contacts = this.getNodeParameter('deleteContacts', i);
                          responseData = await GenericFunctions_1.sendGridApiRequest.call(this, `/marketing/lists/${listId}`, 'DELETE', {}, qs);
                          responseData = { success: true };
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
              if (operation === 'update') {
                  for (let i = 0; i < length; i++) {
                      try {
                          const name = this.getNodeParameter('name', i);
                          const listId = this.getNodeParameter('listId', i);
                          responseData = await GenericFunctions_1.sendGridApiRequest.call(this, `/marketing/lists/${listId}`, 'PATCH', { name }, qs);
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
          }
          if (resource === 'mail') {
              if (operation === 'send') {
                  for (let i = 0; i < length; i++) {
                      try {
                          const toEmail = this.getNodeParameter('toEmail', i);
                          const parsedToEmail = toEmail.includes(',')
                              ? toEmail.split(',').map((entry) => ({ email: entry.trim() }))
                              : [{ email: toEmail.trim() }];
                          const { bccEmail, ccEmail, enableSandbox, sendAt, headers, attachments, categories, ipPoolName, } = this.getNodeParameter('additionalFields', i);
                          const body = {
                              personalizations: [
                                  {
                                      to: parsedToEmail,
                                  },
                              ],
                              from: {
                                  email: this.getNodeParameter('fromEmail', i).trim(),
                                  name: this.getNodeParameter('fromName', i),
                              },
                              mail_settings: {
                                  sandbox_mode: {
                                      enable: enableSandbox || false,
                                  },
                              },
                          };
                          const dynamicTemplateEnabled = this.getNodeParameter('dynamicTemplate', i);
                          if (dynamicTemplateEnabled) {
                              body.template_id = this.getNodeParameter('templateId', i);
                              const { fields } = this.getNodeParameter('dynamicTemplateFields', i);
                              if (fields) {
                                  body.personalizations[0].dynamic_template_data = {};
                                  fields.forEach((field) => {
                                      body.personalizations[0].dynamic_template_data[field.key] = field.value;
                                  });
                              }
                          }
                          else {
                              body.personalizations[0].subject = this.getNodeParameter('subject', i);
                              body.content = [
                                  {
                                      type: this.getNodeParameter('contentType', i),
                                      value: this.getNodeParameter('contentValue', i),
                                  },
                              ];
                          }
                          if (attachments) {
                              const attachmentsToSend = [];
                              const binaryProperties = attachments.split(',').map((p) => p.trim());
                              for (const property of binaryProperties) {
                                  const binaryData = this.helpers.assertBinaryData(i, property);
                                  const dataBuffer = await this.helpers.getBinaryDataBuffer(i, property);
                                  attachmentsToSend.push({
                                      content: dataBuffer.toString('base64'),
                                      filename: binaryData.fileName || 'unknown',
                                      type: binaryData.mimeType,
                                  });
                              }
                              if (attachmentsToSend.length) {
                                  body.attachments = attachmentsToSend;
                              }
                          }
                          if (bccEmail) {
                              body.personalizations[0].bcc = bccEmail
                                  .split(',')
                                  .map((entry) => ({ email: entry.trim() }));
                          }
                          if (ccEmail) {
                              body.personalizations[0].cc = ccEmail
                                  .split(',')
                                  .map((entry) => ({ email: entry.trim() }));
                          }
                          if (headers === null || headers === void 0 ? void 0 : headers.details.length) {
                              const parsedHeaders = {};
                              headers.details.forEach((obj) => (parsedHeaders[obj.key] = obj.value));
                              body.headers = parsedHeaders;
                          }
                          if (categories) {
                              body.categories = categories.split(',');
                          }
                          if (ipPoolName) {
                              body.ip_pool_name = ipPoolName;
                          }
                          if (sendAt) {
                              body.personalizations[0].send_at = moment_timezone_1.default.tz(sendAt, timezone).unix();
                          }
                          const data = await GenericFunctions_1.sendGridApiRequest.call(this, '/mail/send', 'POST', body, qs, {
                              resolveWithFullResponse: true,
                          });
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ messageId: data.headers['x-message-id'] }), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      catch (error) {
                          if (this.continueOnFail()) {
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                              returnData.push(...executionData);
                              continue;
                          }
                          throw error;
                      }
                  }
              }
          }
          return [returnData];
      }
  }
  exports.SendGrid = SendGrid;
  //# sourceMappingURL=SendGrid.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: SendGrid node documentation
  description: Learn how to use the SendGrid node in n8n. Follow technical documentation to integrate SendGrid node into your workflows.
  contentType: [integration, reference]
  priority: medium
  ---

  # SendGrid node

  Use the SendGrid node to automate work in SendGrid, and integrate SendGrid with other applications. n8n has built-in support for a wide range of SendGrid features, including creating, updating, deleting, and getting contacts, and lists, as well as sending emails. 

  On this page, you'll find a list of operations the SendGrid node supports and links to more resources.

  /// note | Credentials
  Refer to [SendGrid credentials](/integrations/builtin/credentials/sendgrid.md) for guidance on setting up authentication. 
  ///

  --8<-- "_snippets/integrations/builtin/app-nodes/ai-tools.md"

  ## Operations

  * Contact
      * Create/update a contact
      * Delete a contact
      * Get a contact by ID
      * Get all contacts
  * List
      * Create a list
      * Delete a list
      * Get a list
      * Get all lists
      * Update a list
  * Mail
      * Send an email.

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'sendgrid') ]]

  --8<-- "_snippets/integrations/builtin/app-nodes/operation-not-supported.md"

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"f897239f-83e6-4957-9504-61d8c48b86ce","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"c2ec0d4e05e77cce5a7df6b3a14d3d366d7cd21cca9bb9a2e2ee078d4494c944"}}


node_type: n8n-nodes-base.SentryIo
name: SentryIo
display_name: Sentry.io
description: Consume Sentry.io API
category: output
icon: file:sentryio.svg
code_hash: 12e647ea8cb08abfa06aba35b9341919467decb8126ef162439de5714292bc31
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.sentryio
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 09:18:27
updated_at: 2025-06-08 09:18:27
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.SentryIo = void 0;
  const EventDescription_1 = require("./EventDescription");
  const IssueDescription_1 = require("./IssueDescription");
  const OrganizationDescription_1 = require("./OrganizationDescription");
  const ProjectDescription_1 = require("./ProjectDescription");
  const ReleaseDescription_1 = require("./ReleaseDescription");
  const TeamDescription_1 = require("./TeamDescription");
  const GenericFunctions_1 = require("./GenericFunctions");
  class SentryIo {
      constructor() {
          this.description = {
              displayName: 'Sentry.io',
              name: 'sentryIo',
              icon: 'file:sentryio.svg',
              group: ['output'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume Sentry.io API',
              defaults: {
                  name: 'Sentry.io',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'sentryIoOAuth2Api',
                      required: true,
                      displayOptions: {
                          show: {
                              authentication: ['oAuth2'],
                              sentryVersion: ['cloud'],
                          },
                      },
                  },
                  {
                      name: 'sentryIoApi',
                      required: true,
                      displayOptions: {
                          show: {
                              authentication: ['accessToken'],
                              sentryVersion: ['cloud'],
                          },
                      },
                  },
                  {
                      name: 'sentryIoServerApi',
                      required: true,
                      displayOptions: {
                          show: {
                              authentication: ['accessToken'],
                              sentryVersion: ['server'],
                          },
                      },
                  },
              ],
              properties: [
                  {
                      displayName: 'Sentry Version',
                      name: 'sentryVersion',
                      type: 'options',
                      options: [
                          {
                              name: 'Cloud',
                              value: 'cloud',
                          },
                          {
                              name: 'Server (Self Hosted)',
                              value: 'server',
                          },
                      ],
                      default: 'cloud',
                  },
                  {
                      displayName: 'Authentication',
                      name: 'authentication',
                      type: 'options',
                      displayOptions: {
                          show: {
                              sentryVersion: ['cloud'],
                          },
                      },
                      options: [
                          {
                              name: 'Access Token',
                              value: 'accessToken',
                          },
                          {
                              name: 'OAuth2',
                              value: 'oAuth2',
                          },
                      ],
                      default: 'accessToken',
                  },
                  {
                      displayName: 'Authentication',
                      name: 'authentication',
                      type: 'options',
                      displayOptions: {
                          show: {
                              sentryVersion: ['server'],
                          },
                      },
                      options: [
                          {
                              name: 'Access Token',
                              value: 'accessToken',
                          },
                      ],
                      default: 'accessToken',
                  },
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Event',
                              value: 'event',
                          },
                          {
                              name: 'Issue',
                              value: 'issue',
                          },
                          {
                              name: 'Organization',
                              value: 'organization',
                          },
                          {
                              name: 'Project',
                              value: 'project',
                          },
                          {
                              name: 'Release',
                              value: 'release',
                          },
                          {
                              name: 'Team',
                              value: 'team',
                          },
                      ],
                      default: 'event',
                  },
                  ...EventDescription_1.eventOperations,
                  ...EventDescription_1.eventFields,
                  ...IssueDescription_1.issueOperations,
                  ...IssueDescription_1.issueFields,
                  ...OrganizationDescription_1.organizationOperations,
                  ...OrganizationDescription_1.organizationFields,
                  ...ProjectDescription_1.projectOperations,
                  ...ProjectDescription_1.projectFields,
                  ...ReleaseDescription_1.releaseOperations,
                  ...ReleaseDescription_1.releaseFields,
                  ...TeamDescription_1.teamOperations,
                  ...TeamDescription_1.teamFields,
              ],
          };
          this.methods = {
              loadOptions: {
                  async getOrganizations() {
                      const returnData = [];
                      const organizations = await GenericFunctions_1.sentryApiRequestAllItems.call(this, 'GET', '/api/0/organizations/', {});
                      for (const organization of organizations) {
                          returnData.push({
                              name: organization.slug,
                              value: organization.slug,
                          });
                      }
                      returnData.sort((a, b) => {
                          if (a.name < b.name) {
                              return -1;
                          }
                          if (a.name > b.name) {
                              return 1;
                          }
                          return 0;
                      });
                      return returnData;
                  },
                  async getProjects() {
                      const returnData = [];
                      const projects = await GenericFunctions_1.sentryApiRequestAllItems.call(this, 'GET', '/api/0/projects/', {});
                      const organizationSlug = this.getNodeParameter('organizationSlug');
                      for (const project of projects) {
                          if (organizationSlug !== project.organization.slug) {
                              continue;
                          }
                          returnData.push({
                              name: project.slug,
                              value: project.slug,
                          });
                      }
                      returnData.sort((a, b) => {
                          if (a.name < b.name) {
                              return -1;
                          }
                          if (a.name > b.name) {
                              return 1;
                          }
                          return 0;
                      });
                      return returnData;
                  },
                  async getTeams() {
                      const returnData = [];
                      const organizationSlug = this.getNodeParameter('organizationSlug');
                      const teams = await GenericFunctions_1.sentryApiRequestAllItems.call(this, 'GET', `/api/0/organizations/${organizationSlug}/teams/`, {});
                      for (const team of teams) {
                          returnData.push({
                              name: team.slug,
                              value: team.slug,
                          });
                      }
                      returnData.sort((a, b) => {
                          if (a.name < b.name) {
                              return -1;
                          }
                          if (a.name > b.name) {
                              return 1;
                          }
                          return 0;
                      });
                      return returnData;
                  },
              },
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          const length = items.length;
          let responseData;
          const qs = {};
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          for (let i = 0; i < length; i++) {
              try {
                  if (resource === 'event') {
                      if (operation === 'getAll') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const projectSlug = this.getNodeParameter('projectSlug', i);
                          const full = this.getNodeParameter('full', i);
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const endpoint = `/api/0/projects/${organizationSlug}/${projectSlug}/events/`;
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.limit = limit;
                          }
                          qs.full = full;
                          responseData = await GenericFunctions_1.sentryApiRequestAllItems.call(this, 'GET', endpoint, {}, qs);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = responseData.splice(0, limit);
                          }
                      }
                      if (operation === 'get') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const projectSlug = this.getNodeParameter('projectSlug', i);
                          const eventId = this.getNodeParameter('eventId', i);
                          const endpoint = `/api/0/projects/${organizationSlug}/${projectSlug}/events/${eventId}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'GET', endpoint, qs);
                      }
                  }
                  if (resource === 'issue') {
                      if (operation === 'getAll') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const projectSlug = this.getNodeParameter('projectSlug', i);
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const endpoint = `/api/0/projects/${organizationSlug}/${projectSlug}/issues/`;
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (additionalFields.statsPeriod) {
                              qs.statsPeriod = additionalFields.statsPeriod;
                          }
                          if (additionalFields.shortIdLookup) {
                              qs.shortIdLookup = additionalFields.shortIdLookup;
                          }
                          if (additionalFields.query) {
                              qs.query = additionalFields.query;
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.limit = limit;
                          }
                          responseData = await GenericFunctions_1.sentryApiRequestAllItems.call(this, 'GET', endpoint, {}, qs);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = responseData.splice(0, limit);
                          }
                      }
                      if (operation === 'get') {
                          const issueId = this.getNodeParameter('issueId', i);
                          const endpoint = `/api/0/issues/${issueId}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'GET', endpoint, qs);
                      }
                      if (operation === 'delete') {
                          const issueId = this.getNodeParameter('issueId', i);
                          const endpoint = `/api/0/issues/${issueId}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'DELETE', endpoint, qs);
                          responseData = { success: true };
                      }
                      if (operation === 'update') {
                          const issueId = this.getNodeParameter('issueId', i);
                          const endpoint = `/api/0/issues/${issueId}/`;
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (additionalFields.status) {
                              qs.status = additionalFields.status;
                          }
                          if (additionalFields.assignedTo) {
                              qs.assignedTo = additionalFields.assignedTo;
                          }
                          if (additionalFields.hasSeen) {
                              qs.hasSeen = additionalFields.hasSeen;
                          }
                          if (additionalFields.isBookmarked) {
                              qs.isBookmarked = additionalFields.isBookmarked;
                          }
                          if (additionalFields.isSubscribed) {
                              qs.isSubscribed = additionalFields.isSubscribed;
                          }
                          if (additionalFields.isPublic) {
                              qs.isPublic = additionalFields.isPublic;
                          }
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'PUT', endpoint, qs);
                      }
                  }
                  if (resource === 'organization') {
                      if (operation === 'get') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const endpoint = `/api/0/organizations/${organizationSlug}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'GET', endpoint, qs);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const endpoint = '/api/0/organizations/';
                          if (additionalFields.member) {
                              qs.member = additionalFields.member;
                          }
                          if (additionalFields.owner) {
                              qs.owner = additionalFields.owner;
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.limit = limit;
                          }
                          responseData = await GenericFunctions_1.sentryApiRequestAllItems.call(this, 'GET', endpoint, {}, qs);
                          if (responseData === undefined) {
                              responseData = [];
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = responseData.splice(0, limit);
                          }
                      }
                      if (operation === 'create') {
                          const name = this.getNodeParameter('name', i);
                          const agreeTerms = this.getNodeParameter('agreeTerms', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const endpoint = '/api/0/organizations/';
                          qs.name = name;
                          qs.agreeTerms = agreeTerms;
                          if (additionalFields.slug) {
                              qs.slug = additionalFields.slug;
                          }
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'POST', endpoint, qs);
                      }
                      if (operation === 'update') {
                          const organizationSlug = this.getNodeParameter('organization_slug', i);
                          const endpoint = `/api/0/organizations/${organizationSlug}/`;
                          const body = this.getNodeParameter('updateFields', i);
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'PUT', endpoint, body, qs);
                      }
                  }
                  if (resource === 'project') {
                      if (operation === 'create') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const teamSlug = this.getNodeParameter('teamSlug', i);
                          const name = this.getNodeParameter('name', i);
                          const endpoint = `/api/0/teams/${organizationSlug}/${teamSlug}/projects/`;
                          const body = {
                              name,
                              ...this.getNodeParameter('additionalFields', i),
                          };
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'POST', endpoint, body, qs);
                      }
                      if (operation === 'get') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const projectSlug = this.getNodeParameter('projectSlug', i);
                          const endpoint = `/api/0/projects/${organizationSlug}/${projectSlug}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'GET', endpoint, qs);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const endpoint = '/api/0/projects/';
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.limit = limit;
                          }
                          responseData = await GenericFunctions_1.sentryApiRequestAllItems.call(this, 'GET', endpoint, {}, qs);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = responseData.splice(0, limit);
                          }
                      }
                      if (operation === 'update') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const projectSlug = this.getNodeParameter('projectSlug', i);
                          const endpoint = `/api/0/projects/${organizationSlug}/${projectSlug}/`;
                          const body = this.getNodeParameter('updateFields', i);
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'PUT', endpoint, body, qs);
                      }
                      if (operation === 'delete') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const projectSlug = this.getNodeParameter('projectSlug', i);
                          const endpoint = `/api/0/projects/${organizationSlug}/${projectSlug}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'DELETE', endpoint, qs);
                          responseData = { success: true };
                      }
                  }
                  if (resource === 'release') {
                      if (operation === 'get') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const version = this.getNodeParameter('version', i);
                          const endpoint = `/api/0/organizations/${organizationSlug}/releases/${version}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'GET', endpoint, qs);
                      }
                      if (operation === 'getAll') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const endpoint = `/api/0/organizations/${organizationSlug}/releases/`;
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const returnAll = this.getNodeParameter('returnAll', i);
                          if (additionalFields.query) {
                              qs.query = additionalFields.query;
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.limit = limit;
                          }
                          responseData = await GenericFunctions_1.sentryApiRequestAllItems.call(this, 'GET', endpoint, {}, qs);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = responseData.splice(0, limit);
                          }
                      }
                      if (operation === 'delete') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const version = this.getNodeParameter('version', i);
                          const endpoint = `/api/0/organizations/${organizationSlug}/releases/${version}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'DELETE', endpoint, qs);
                          responseData = { success: true };
                      }
                      if (operation === 'create') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const endpoint = `/api/0/organizations/${organizationSlug}/releases/`;
                          const version = this.getNodeParameter('version', i);
                          const url = this.getNodeParameter('url', i);
                          const projects = this.getNodeParameter('projects', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (additionalFields.dateReleased) {
                              qs.dateReleased = additionalFields.dateReleased;
                          }
                          qs.version = version;
                          qs.url = url;
                          qs.projects = projects;
                          if (additionalFields.commits) {
                              const commits = [];
                              additionalFields.commits.commitProperties.map((commit) => {
                                  const commitObject = { id: commit.id };
                                  if (commit.repository) {
                                      commitObject.repository = commit.repository;
                                  }
                                  if (commit.message) {
                                      commitObject.message = commit.message;
                                  }
                                  if (commit.patchSet && Array.isArray(commit.patchSet)) {
                                      commit.patchSet.patchSetProperties.map((patchSet) => {
                                          var _a;
                                          (_a = commitObject.patch_set) === null || _a === void 0 ? void 0 : _a.push(patchSet);
                                      });
                                  }
                                  if (commit.authorName) {
                                      commitObject.author_name = commit.authorName;
                                  }
                                  if (commit.authorEmail) {
                                      commitObject.author_email = commit.authorEmail;
                                  }
                                  if (commit.timestamp) {
                                      commitObject.timestamp = commit.timestamp;
                                  }
                                  commits.push(commitObject);
                              });
                              qs.commits = commits;
                          }
                          if (additionalFields.refs) {
                              const refs = [];
                              additionalFields.refs.refProperties.map((ref) => {
                                  refs.push(ref);
                              });
                              qs.refs = refs;
                          }
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'POST', endpoint, qs);
                      }
                      if (operation === 'update') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const version = this.getNodeParameter('version', i);
                          const endpoint = `/api/0/organizations/${organizationSlug}/releases/${version}/`;
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = { ...updateFields };
                          if (updateFields.commits) {
                              const commits = [];
                              updateFields.commits.commitProperties.map((commit) => {
                                  const commitObject = { id: commit.id };
                                  if (commit.repository) {
                                      commitObject.repository = commit.repository;
                                  }
                                  if (commit.message) {
                                      commitObject.message = commit.message;
                                  }
                                  if (commit.patchSet && Array.isArray(commit.patchSet)) {
                                      commit.patchSet.patchSetProperties.map((patchSet) => {
                                          var _a;
                                          (_a = commitObject.patch_set) === null || _a === void 0 ? void 0 : _a.push(patchSet);
                                      });
                                  }
                                  if (commit.authorName) {
                                      commitObject.author_name = commit.authorName;
                                  }
                                  if (commit.authorEmail) {
                                      commitObject.author_email = commit.authorEmail;
                                  }
                                  if (commit.timestamp) {
                                      commitObject.timestamp = commit.timestamp;
                                  }
                                  commits.push(commitObject);
                              });
                              body.commits = commits;
                          }
                          if (updateFields.refs) {
                              const refs = [];
                              updateFields.refs.refProperties.map((ref) => {
                                  refs.push(ref);
                              });
                              body.refs = refs;
                          }
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'PUT', endpoint, body, qs);
                      }
                  }
                  if (resource === 'team') {
                      if (operation === 'get') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const teamSlug = this.getNodeParameter('teamSlug', i);
                          const endpoint = `/api/0/teams/${organizationSlug}/${teamSlug}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'GET', endpoint, qs);
                      }
                      if (operation === 'getAll') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const endpoint = `/api/0/organizations/${organizationSlug}/teams/`;
                          const returnAll = this.getNodeParameter('returnAll', i);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.limit = limit;
                          }
                          responseData = await GenericFunctions_1.sentryApiRequestAllItems.call(this, 'GET', endpoint, {}, qs);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = responseData.splice(0, limit);
                          }
                      }
                      if (operation === 'create') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const name = this.getNodeParameter('name', i);
                          const endpoint = `/api/0/organizations/${organizationSlug}/teams/`;
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          qs.name = name;
                          if (additionalFields.slug) {
                              qs.slug = additionalFields.slug;
                          }
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'POST', endpoint, qs);
                      }
                      if (operation === 'update') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const teamSlug = this.getNodeParameter('teamSlug', i);
                          const endpoint = `/api/0/teams/${organizationSlug}/${teamSlug}/`;
                          const body = this.getNodeParameter('updateFields', i);
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'PUT', endpoint, body, qs);
                      }
                      if (operation === 'delete') {
                          const organizationSlug = this.getNodeParameter('organizationSlug', i);
                          const teamSlug = this.getNodeParameter('teamSlug', i);
                          const endpoint = `/api/0/teams/${organizationSlug}/${teamSlug}/`;
                          responseData = await GenericFunctions_1.sentryIoApiRequest.call(this, 'DELETE', endpoint, qs);
                          responseData = { success: true };
                      }
                  }
                  const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                  returnData.push(...executionData);
              }
              catch (error) {
                  if (this.continueOnFail()) {
                      const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                      returnData.push(...executionErrorData);
                      continue;
                  }
                  throw error;
              }
          }
          return [returnData];
      }
  }
  exports.SentryIo = SentryIo;
  //# sourceMappingURL=SentryIo.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Sentry.io node documentation
  description: Learn how to use the Sentry.io node in n8n. Follow technical documentation to integrate Sentry.io node into your workflows.
  contentType: [integration, reference]
  ---

  # Sentry.io node

  Use the Sentry.io node to automate work in Sentry.io, and integrate Sentry.io with other applications. n8n has built-in support for a wide range of Sentry.io features, including creating, updating, deleting, and getting, issues, projects, and releases, as well as getting all events.

  On this page, you'll find a list of operations the Sentry.io node supports and links to more resources.

  /// note | Credentials
  Refer to [Sentry.io credentials](/integrations/builtin/credentials/sentryio.md) for guidance on setting up authentication. 
  ///

  ## Operations

  * Event
      * Get event by ID
      * Get all events
  * Issue
      * Delete an issue
      * Get issue by ID
      * Get all issues
      * Update an issue
  * Project
      * Create a new project
      * Delete a project
      * Get project by ID
      * Get all projects
      * Update a project
  * Release
      * Create a release
      * Delete a release
      * Get release by version identifier
      * Get all releases
      * Update a release
  * Organization
      * Create an organization
      * Get organization by slug
      * Get all organizations
      * Update an organization
  * Team
      * Create a new team
      * Delete a team
      * Get team by slug
      * Get all teams
      * Update a team

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'sentryio') ]]

  ## Related resources

  Refer to [Sentry.io's documentation](https://docs.sentry.io/api/){:target=_blank .external-link} for more information about the service.

  --8<-- "_snippets/integrations/builtin/app-nodes/operation-not-supported.md"

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"bea704a2-642e-4224-abff-a15a47443e22","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"7451e60ff159ae5b1f32554dadc099b6119ff5c3715a20a10b583a940b8fc14e"}}


node_type: n8n-nodes-base.Sendy
name: Sendy
display_name: Sendy
description: Consume Sendy API
category: input
icon: file:sendy.png
code_hash: 8f1551f664c318139782631bc2298a5dc48d279198dcc99bfff803806441c8ab
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.sendy
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 09:18:27
updated_at: 2025-06-08 09:18:27
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Sendy = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const GenericFunctions_1 = require("./GenericFunctions");
  const CampaignDescription_1 = require("./CampaignDescription");
  const SubscriberDescription_1 = require("./SubscriberDescription");
  class Sendy {
      constructor() {
          this.description = {
              displayName: 'Sendy',
              name: 'sendy',
              icon: 'file:sendy.png',
              group: ['input'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume Sendy API',
              defaults: {
                  name: 'Sendy',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'sendyApi',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Campaign',
                              value: 'campaign',
                          },
                          {
                              name: 'Subscriber',
                              value: 'subscriber',
                          },
                      ],
                      default: 'subscriber',
                  },
                  ...CampaignDescription_1.campaignOperations,
                  ...CampaignDescription_1.campaignFields,
                  ...SubscriberDescription_1.subscriberOperations,
                  ...SubscriberDescription_1.subscriberFields,
              ],
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          const length = items.length;
          let responseData;
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          for (let i = 0; i < length; i++) {
              if (resource === 'campaign') {
                  if (operation === 'create') {
                      const fromName = this.getNodeParameter('fromName', i);
                      const fromEmail = this.getNodeParameter('fromEmail', i);
                      const replyTo = this.getNodeParameter('replyTo', i);
                      const title = this.getNodeParameter('title', i);
                      const subject = this.getNodeParameter('subject', i);
                      const htmlText = this.getNodeParameter('htmlText', i);
                      const sendCampaign = this.getNodeParameter('sendCampaign', i);
                      const additionalFields = this.getNodeParameter('additionalFields', i);
                      let brandId = null;
                      if (!sendCampaign) {
                          brandId = this.getNodeParameter('brandId', i);
                      }
                      const body = {
                          from_name: fromName,
                          from_email: fromEmail,
                          reply_to: replyTo,
                          title,
                          subject,
                          send_campaign: sendCampaign ? 1 : 0,
                          html_text: htmlText,
                      };
                      if (brandId) {
                          body.brand_id = brandId;
                      }
                      if (additionalFields.plainText) {
                          body.plain_text = additionalFields.plainText;
                      }
                      if (additionalFields.listIds) {
                          body.list_ids = additionalFields.listIds;
                      }
                      if (additionalFields.segmentIds) {
                          body.segment_ids = additionalFields.segmentIds;
                      }
                      if (additionalFields.excludeListIds) {
                          body.exclude_list_ids = additionalFields.excludeListIds;
                      }
                      if (additionalFields.excludeSegmentIds) {
                          body.exclude_segments_ids = additionalFields.excludeSegmentIds;
                      }
                      if (additionalFields.queryString) {
                          body.query_string = additionalFields.queryString;
                      }
                      if (additionalFields.trackOpens) {
                          body.track_opens = additionalFields.trackOpens ? 1 : 0;
                      }
                      if (additionalFields.trackClicks) {
                          body.track_clicks = additionalFields.trackClicks ? 1 : 0;
                      }
                      responseData = await GenericFunctions_1.sendyApiRequest.call(this, 'POST', '/api/campaigns/create.php', body);
                      const success = ['Campaign created', 'Campaign created and now sending'];
                      if (success.includes(responseData)) {
                          responseData = { message: responseData };
                      }
                      else {
                          throw new n8n_workflow_1.NodeApiError(this.getNode(), responseData, { httpCode: '400' });
                      }
                  }
              }
              if (resource === 'subscriber') {
                  if (operation === 'add') {
                      const email = this.getNodeParameter('email', i);
                      const listId = this.getNodeParameter('listId', i);
                      const additionalFields = this.getNodeParameter('additionalFields', i);
                      const body = {
                          email,
                          list: listId,
                      };
                      Object.assign(body, additionalFields);
                      responseData = await GenericFunctions_1.sendyApiRequest.call(this, 'POST', '/subscribe', body);
                      if (responseData === '1') {
                          responseData = { success: true };
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Sendy error response [${400}]: ${responseData}`, { itemIndex: i });
                      }
                  }
                  if (operation === 'count') {
                      const listId = this.getNodeParameter('listId', i);
                      const body = {
                          list_id: listId,
                      };
                      responseData = await GenericFunctions_1.sendyApiRequest.call(this, 'POST', '/api/subscribers/active-subscriber-count.php', body);
                      const errors = [
                          'No data passed',
                          'API key not passed',
                          'Invalid API key',
                          'List ID not passed',
                          'List does not exist',
                      ];
                      if (!errors.includes(responseData)) {
                          responseData = { count: responseData };
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Sendy error response [${400}]: ${responseData}`, { itemIndex: i });
                      }
                  }
                  if (operation === 'delete') {
                      const email = this.getNodeParameter('email', i);
                      const listId = this.getNodeParameter('listId', i);
                      const body = {
                          email,
                          list_id: listId,
                      };
                      responseData = await GenericFunctions_1.sendyApiRequest.call(this, 'POST', '/api/subscribers/delete.php', body);
                      if (responseData === '1') {
                          responseData = { success: true };
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Sendy error response [${400}]: ${responseData}`, { itemIndex: i });
                      }
                  }
                  if (operation === 'remove') {
                      const email = this.getNodeParameter('email', i);
                      const listId = this.getNodeParameter('listId', i);
                      const body = {
                          email,
                          list: listId,
                      };
                      responseData = await GenericFunctions_1.sendyApiRequest.call(this, 'POST', '/unsubscribe', body);
                      if (responseData === '1') {
                          responseData = { success: true };
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Sendy error response [${400}]: ${responseData}`, { itemIndex: i });
                      }
                  }
                  if (operation === 'status') {
                      const email = this.getNodeParameter('email', i);
                      const listId = this.getNodeParameter('listId', i);
                      const body = {
                          email,
                          list_id: listId,
                      };
                      responseData = await GenericFunctions_1.sendyApiRequest.call(this, 'POST', '/api/subscribers/subscription-status.php', body);
                      const status = [
                          'Subscribed',
                          'Unsubscribed',
                          'Unconfirmed',
                          'Bounced',
                          'Soft bounced',
                          'Complained',
                      ];
                      if (status.includes(responseData)) {
                          responseData = { status: responseData };
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Sendy error response [${400}]: ${responseData}`, { itemIndex: i });
                      }
                  }
              }
          }
          if (Array.isArray(responseData)) {
              returnData.push.apply(returnData, responseData);
          }
          else if (responseData !== undefined) {
              returnData.push(responseData);
          }
          return [this.helpers.returnJsonArray(returnData)];
      }
  }
  exports.Sendy = Sendy;
  //# sourceMappingURL=Sendy.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Sendy node documentation
  description: Learn how to use the Sendy node in n8n. Follow technical documentation to integrate Sendy node into your workflows.
  contentType: [integration, reference]
  ---

  # Sendy node

  Use the Sendy node to automate work in Sendy, and integrate Sendy with other applications. n8n has built-in support for a wide range of Sendy features, including creating campaigns, and adding, counting, deleting, and getting subscribers.

  On this page, you'll find a list of operations the Sendy node supports and links to more resources.

  /// note | Credentials
  Refer to [Sendy credentials](/integrations/builtin/credentials/sendy.md) for guidance on setting up authentication. 
  ///

  ## Operations

  * Campaign
      * Create a campaign
  * Subscriber
      * Add a subscriber to a list
      * Count subscribers
      * Delete a subscriber from a list
      * Unsubscribe user from a list
      * Get the status of subscriber

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'sendy') ]]

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"87815598-c898-4844-80b4-ccba39c9f364","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"e571d75dcb96c9e5baf2a4952ef381a01b588230daa616e71dbe0a74f9e7ef23"}}


node_type: n8n-nodes-base.Set
name: Set
display_name: Set
description: Add or edit fields on an input item and optionally remove other fields
category: input
icon: fa:pen
code_hash: 4414ad216090aa4ae629fc2ed5ae175c48bde7392d1133b82f472edcd1620065
documentation_url: https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.comparedatasets
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
extracted_at: 2025-06-08 09:18:27
updated_at: 2025-06-08 09:18:27
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Set = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const SetV1_node_1 = require("./v1/SetV1.node");
  const SetV2_node_1 = require("./v2/SetV2.node");
  class Set extends n8n_workflow_1.VersionedNodeType {
      constructor() {
          const baseDescription = {
              displayName: 'Set',
              name: 'set',
              icon: 'fa:pen',
              group: ['input'],
              description: 'Add or edit fields on an input item and optionally remove other fields',
              defaultVersion: 3.2,
          };
          const nodeVersions = {
              1: new SetV1_node_1.SetV1(baseDescription),
              2: new SetV1_node_1.SetV1(baseDescription),
              3: new SetV2_node_1.SetV2(baseDescription),
              3.1: new SetV2_node_1.SetV2(baseDescription),
              3.2: new SetV2_node_1.SetV2(baseDescription),
          };
          super(nodeVersions, baseDescription);
      }
  }
  exports.Set = Set;
  //# sourceMappingURL=Set.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Compare Datasets
  description: Documentation for the Compare Datasets node in n8n, a workflow automation platform. Includes guidance on usage, and links to examples.
  contentType: [integration, reference]
  priority: high
  ---

  # Compare Datasets

  The Compare Datasets node helps you compare data from two input streams.

  ## Node parameters

  1. Decide which fields to compare. In **Input A Field**, enter the name of the field you want to use from input stream A. In **Input B Field**, enter the name of the field you want to use from input stream B. 
  2. **Optional**: You can compare by multiple fields. Select **Add Fields to Match** to set up more comparisons.
  3. Choose how to handle differences between the datasets. In **When There Are Differences**, select one of the following:
  	* **Use Input A Version** to treat input stream A as the source of truth.
  	* **Use Input B Version** to treat input stream B as the source of truth.
  	* **Use a Mix of Versions** to use different inputs for different fields.
  		* Use **Prefer** to select either **Input A Version** or **Input B Version** as the main source of truth.
  		* Enter input fields that are exceptions to **For Everything Except** to pull from the other input source. To add multiple input fields, enter a comma-separated list.
  	* **Include Both Versions** to include both input streams in the output, which may make the structure more complex.
  4. Decide whether to use **Fuzzy Compare**. When turned on, the comparison will tolerate small type differences when comparing fields. For example, the number 3 and the string `3` are treated as the same with **Fuzzy Compare** turned on, but wouldn't be treated the same with it turned off.

  ## Understand item comparison

  Item comparison is a two stage process:

  1. n8n checks if the values of the fields you selected to compare match across both inputs.
  2. If the fields to compare match, n8n then compares all fields within the items, to determine if the items are the same or different.

  ## Node options

  Use the node **Options** to refine your comparison or tweak comparison behavior.

  ### Fields to Skip Comparing

  Enter field names that you want to ignore in the comparison.

  For example, if you compare the two datasets below using `person.language` as the **Fields to Match**, n8n returns them as different. If you add `person.name` to **Fields to Skip Comparing**, n8n returns them as matching.

  ```json
  	// Input 1
  	[
  		{
  			"person":
  			{
  				"name":	"Stefan",
  				"language":	"de"
  			}
  		},
  		{
  			"person":
  			{
  				"name":	"Jim",
  				"language":	"en"
  			}
  		},
  		{
  			"person":
  			{
  				"name":	"Hans",
  				"language":	"de"
  			}
  		}
  	]
  	// Input 2
  		[
  		{
  			"person":
  			{
  				"name":	"Sara",
  				"language":	"de"
  			}
  		},
  		{
  			"person":
  			{
  				"name":	"Jane",
  				"language":	"en"
  			}
  		},
  		{
  			"person":
  			{
  				"name":	"Harriet",
  				"language":	"de"
  			}
  		}
  	]
  ```

  ### Disable Dot Notation

  Whether to disallow referencing child fields using `parent.child` in the field name (turned on) or allow it (turned off, default).

  ### Multiple Matches

  Choose how to handle duplicate data. The default is **Include All Matches**. You can choose **Include First Match Only**.

  For example, given these two datasets:
  ```json
  	// Input 1
  	[
  		{
  			"fruit": {
  				"type": "apple",
  				"color": "red"
  			}
  		},
  				{
  			"fruit": {
  				"type": "apple",
  				"color": "red"
  			}
  		},
  				{
  			"fruit": {
  				"type": "banana",
  				"color": "yellow"
  			}
  		}
  	]
  	// Input 2
  	[
  		{
  			"fruit": {
  				"type": "apple",
  				"color": "red"
  			}
  		},
  				{
  			"fruit": {
  				"type": "apple",
  				"color": "red"
  			}
  		},
  				{
  			"fruit": {
  				"type": "banana",
  				"color": "yellow"
  			}
  		}
  	]
  ```

  n8n returns three items in the **Same Branch** tab. The data is the same in both branches.

  If you select **Include First Match Only**, n8n returns two items, in the **Same Branch** tab. The data is the same in both branches, but n8n only returns the first occurrence of the matching "apple" items.


  ## Understand the output

  There are four output options:

  * **In A only Branch**: Contains data that occurs only in the first input.
  * **Same Branch**: Contains data that's the same in both inputs.
  * **Different Branch**: Contains data that's different between inputs.
  * **In B only Branch**: Contains data that occurs only in the second output.

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'compare-datasets') ]]

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"61c1a70a-cbd4-41e7-bfbe-daff9f440beb","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"c6ed3d4b40ad87f69f7a93bc5f5edd7766691762a2fa8ed2d2800d601114562e"}}


node_type: n8n-nodes-base.ServiceNow
name: ServiceNow
display_name: ServiceNow
description: Consume ServiceNow API
category: output
icon: file:servicenow.svg
code_hash: ff46288455e6d2f1a7f7f9bd7f3b80f839079d11a53c14846d3bf88f7f162af2
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.servicenow
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 09:18:28
updated_at: 2025-06-08 09:18:28
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.ServiceNow = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const GenericFunctions_1 = require("./GenericFunctions");
  const AttachmentDescription_1 = require("./AttachmentDescription");
  const BusinessServiceDescription_1 = require("./BusinessServiceDescription");
  const ConfigurationItemsDescription_1 = require("./ConfigurationItemsDescription");
  const DepartmentDescription_1 = require("./DepartmentDescription");
  const DictionaryDescription_1 = require("./DictionaryDescription");
  const IncidentDescription_1 = require("./IncidentDescription");
  const TableRecordDescription_1 = require("./TableRecordDescription");
  const UserDescription_1 = require("./UserDescription");
  const UserGroupDescription_1 = require("./UserGroupDescription");
  const UserRoleDescription_1 = require("./UserRoleDescription");
  class ServiceNow {
      constructor() {
          this.description = {
              displayName: 'ServiceNow',
              name: 'serviceNow',
              icon: 'file:servicenow.svg',
              group: ['output'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume ServiceNow API',
              defaults: {
                  name: 'ServiceNow',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'serviceNowOAuth2Api',
                      required: true,
                      displayOptions: {
                          show: {
                              authentication: ['oAuth2'],
                          },
                      },
                  },
                  {
                      name: 'serviceNowBasicApi',
                      required: true,
                      displayOptions: {
                          show: {
                              authentication: ['basicAuth'],
                          },
                      },
                  },
              ],
              properties: [
                  {
                      displayName: 'Authentication',
                      name: 'authentication',
                      type: 'options',
                      options: [
                          {
                              name: 'Basic Auth',
                              value: 'basicAuth',
                          },
                          {
                              name: 'OAuth2',
                              value: 'oAuth2',
                          },
                      ],
                      default: 'oAuth2',
                      description: 'Authentication method to use',
                  },
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Attachment',
                              value: 'attachment',
                          },
                          {
                              name: 'Business Service',
                              value: 'businessService',
                          },
                          {
                              name: 'Configuration Item',
                              value: 'configurationItems',
                          },
                          {
                              name: 'Department',
                              value: 'department',
                          },
                          {
                              name: 'Dictionary',
                              value: 'dictionary',
                          },
                          {
                              name: 'Incident',
                              value: 'incident',
                          },
                          {
                              name: 'Table Record',
                              value: 'tableRecord',
                          },
                          {
                              name: 'User',
                              value: 'user',
                          },
                          {
                              name: 'User Group',
                              value: 'userGroup',
                          },
                          {
                              name: 'User Role',
                              value: 'userRole',
                          },
                      ],
                      default: 'user',
                  },
                  ...AttachmentDescription_1.attachmentOperations,
                  ...AttachmentDescription_1.attachmentFields,
                  ...BusinessServiceDescription_1.businessServiceOperations,
                  ...BusinessServiceDescription_1.businessServiceFields,
                  ...ConfigurationItemsDescription_1.configurationItemsOperations,
                  ...ConfigurationItemsDescription_1.configurationItemsFields,
                  ...DepartmentDescription_1.departmentOperations,
                  ...DepartmentDescription_1.departmentFields,
                  ...DictionaryDescription_1.dictionaryOperations,
                  ...DictionaryDescription_1.dictionaryFields,
                  ...IncidentDescription_1.incidentOperations,
                  ...IncidentDescription_1.incidentFields,
                  ...TableRecordDescription_1.tableRecordOperations,
                  ...TableRecordDescription_1.tableRecordFields,
                  ...UserDescription_1.userOperations,
                  ...UserDescription_1.userFields,
                  ...UserGroupDescription_1.userGroupOperations,
                  ...UserGroupDescription_1.userGroupFields,
                  ...UserRoleDescription_1.userRoleOperations,
                  ...UserRoleDescription_1.userRoleFields,
              ],
          };
          this.methods = {
              loadOptions: {
                  async getTables() {
                      const returnData = [];
                      const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/doc/table/schema', {}, {});
                      for (const table of response.result) {
                          returnData.push({
                              name: table.label,
                              value: table.value,
                              description: table.value,
                          });
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getColumns() {
                      const resource = this.getNodeParameter('resource', 0);
                      const operation = this.getNodeParameter('operation', 0);
                      const returnData = [];
                      let tableName;
                      if (resource === 'tableRecord') {
                          tableName = this.getNodeParameter('tableName');
                      }
                      else {
                          tableName = (0, GenericFunctions_1.mapEndpoint)(resource, operation);
                      }
                      const qs = {
                          sysparm_query: `name=${tableName}`,
                          sysparm_fields: 'column_label,element',
                      };
                      const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/sys_dictionary', {}, qs);
                      for (const column of response.result) {
                          if (column.element) {
                              returnData.push({
                                  name: column.column_label,
                                  value: column.element,
                              });
                          }
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getBusinessServices() {
                      const returnData = [];
                      const qs = {
                          sysparm_fields: 'name,sys_id',
                      };
                      const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/cmdb_ci_service', {}, qs);
                      for (const column of response.result) {
                          returnData.push({
                              name: column.name,
                              value: column.sys_id,
                          });
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getUsers() {
                      const returnData = [];
                      const resource = this.getNodeParameter('resource', 0);
                      const operation = this.getNodeParameter('operation', 0);
                      const qs = {
                          sysparm_fields: 'sys_id,user_name',
                      };
                      if (resource === 'incident' && operation === 'create') {
                          const additionalFields = this.getNodeParameter('additionalFields');
                          const group = additionalFields.assignment_group;
                          const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user_grmember', {}, {
                              sysparm_query: `group=${group}^`,
                          });
                          for (const column of response) {
                              if (column.user) {
                                  const responseData = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', `/now/table/sys_user/${column.user.value}`, {}, {});
                                  const user = responseData.result;
                                  returnData.push({
                                      name: user.user_name,
                                      value: user.sys_id,
                                  });
                              }
                          }
                      }
                      else {
                          const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user', {}, qs);
                          for (const column of response) {
                              if (column.user_name) {
                                  returnData.push({
                                      name: column.user_name,
                                      value: column.sys_id,
                                  });
                              }
                          }
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getAssignmentGroups() {
                      const returnData = [];
                      const qs = {
                          sysparm_fields: 'sys_id,name',
                      };
                      const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user_group', {}, qs);
                      for (const column of response) {
                          if (column.name) {
                              returnData.push({
                                  name: column.name,
                                  value: column.sys_id,
                              });
                          }
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getUserRoles() {
                      const returnData = [];
                      const qs = {
                          sysparm_fields: 'sys_id,name',
                      };
                      const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user_role', {}, qs);
                      for (const column of response) {
                          if (column.name) {
                              returnData.push({
                                  name: column.name,
                                  value: column.sys_id,
                              });
                          }
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getConfigurationItems() {
                      const returnData = [];
                      const qs = {
                          sysparm_fields: 'sys_id,name,sys_class_name',
                      };
                      const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/cmdb_ci', {}, qs);
                      for (const column of response) {
                          if (column.name) {
                              returnData.push({
                                  name: column.name,
                                  value: column.sys_id,
                                  description: column.sys_class_name,
                              });
                          }
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getIncidentCategories() {
                      const returnData = [];
                      const qs = {
                          sysparm_fields: 'label,value',
                          sysparm_query: 'element=category^name=incident',
                      };
                      const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_choice', {}, qs);
                      for (const column of response) {
                          returnData.push({
                              name: column.label,
                              value: column.value,
                          });
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getIncidentSubcategories() {
                      const returnData = [];
                      const operation = this.getNodeParameter('operation');
                      let category;
                      if (operation === 'update') {
                          const updateFields = this.getNodeParameter('updateFields');
                          category = updateFields.category;
                      }
                      else {
                          const additionalFields = this.getNodeParameter('additionalFields');
                          category = additionalFields.category;
                      }
                      const qs = {
                          sysparm_fields: 'label,value',
                          sysparm_query: `name=incident^element=subcategory^dependent_value=${category}`,
                      };
                      const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_choice', {}, qs);
                      for (const column of response) {
                          returnData.push({
                              name: column.label,
                              value: column.value,
                          });
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getIncidentStates() {
                      const returnData = [];
                      const qs = {
                          sysparm_fields: 'label,value',
                          sysparm_query: 'element=state^name=incident',
                      };
                      const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_choice', {}, qs);
                      for (const column of response) {
                          returnData.push({
                              name: column.label,
                              value: column.value,
                          });
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getIncidentResolutionCodes() {
                      const returnData = [];
                      const qs = {
                          sysparm_fields: 'label,value',
                          sysparm_query: 'element=close_code^name=incident',
                      };
                      const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_choice', {}, qs);
                      for (const column of response) {
                          returnData.push({
                              name: column.label,
                              value: column.value,
                          });
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
                  async getIncidentHoldReasons() {
                      const returnData = [];
                      const qs = {
                          sysparm_fields: 'label,value',
                          sysparm_query: 'element=hold_reason^name=incident',
                      };
                      const response = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_choice', {}, qs);
                      for (const column of response) {
                          returnData.push({
                              name: column.label,
                              value: column.value,
                          });
                      }
                      return (0, GenericFunctions_1.sortData)(returnData);
                  },
              },
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          const length = items.length;
          let responseData = {};
          let qs;
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          for (let i = 0; i < length; i++) {
              try {
                  if (resource === 'attachment') {
                      if (operation === 'get') {
                          const attachmentsSysId = this.getNodeParameter('attachmentId', i);
                          const download = this.getNodeParameter('download', i);
                          const endpoint = `/now/attachment/${attachmentsSysId}`;
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', endpoint, {});
                          const fileMetadata = response.result;
                          responseData = {
                              json: fileMetadata,
                          };
                          if (download) {
                              const outputField = this.getNodeParameter('outputField', i);
                              responseData = {
                                  ...responseData,
                                  binary: {
                                      [outputField]: await GenericFunctions_1.serviceNowDownloadAttachment.call(this, endpoint, fileMetadata.file_name, fileMetadata.content_type),
                                  },
                              };
                          }
                      }
                      else if (operation === 'getAll') {
                          const download = this.getNodeParameter('download', i);
                          const tableName = this.getNodeParameter('tableName', i);
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          qs = {};
                          qs.sysparm_query = `table_name=${tableName}`;
                          if (options.queryFilter) {
                              qs.sysparm_query = `${qs.sysparm_query}^${options.queryFilter}`;
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/attachment', {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/attachment', {}, qs);
                          }
                          if (download) {
                              const outputField = this.getNodeParameter('outputField', i);
                              const responseDataWithAttachments = [];
                              for (const data of responseData) {
                                  responseDataWithAttachments.push({
                                      json: data,
                                      binary: {
                                          [outputField]: await GenericFunctions_1.serviceNowDownloadAttachment.call(this, `/now/attachment/${data.sys_id}`, data.file_name, data.content_type),
                                      },
                                  });
                              }
                              responseData = responseDataWithAttachments;
                          }
                          else {
                              responseData = responseData.map((data) => ({ json: data }));
                          }
                      }
                      else if (operation === 'upload') {
                          const tableName = this.getNodeParameter('tableName', i);
                          const recordId = this.getNodeParameter('id', i);
                          const inputDataFieldName = this.getNodeParameter('inputDataFieldName', i);
                          const options = this.getNodeParameter('options', i);
                          const binaryData = this.helpers.assertBinaryData(i, inputDataFieldName);
                          const headers = {
                              'Content-Type': binaryData.mimeType,
                          };
                          const query = {
                              table_name: tableName,
                              table_sys_id: recordId,
                              file_name: binaryData.fileName
                                  ? binaryData.fileName
                                  : `${inputDataFieldName}.${binaryData.fileExtension}`,
                              ...options,
                          };
                          const body = await this.helpers.getBinaryDataBuffer(i, inputDataFieldName);
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'POST', '/now/attachment/file', body, query, '', { headers });
                          responseData = response.result;
                      }
                      else if (operation === 'delete') {
                          const attachmentsSysId = this.getNodeParameter('attachmentId', i);
                          await GenericFunctions_1.serviceNowApiRequest.call(this, 'DELETE', `/now/attachment/${attachmentsSysId}`);
                          responseData = { success: true };
                      }
                  }
                  else if (resource === 'businessService') {
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/cmdb_ci_service', {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/cmdb_ci_service', {}, qs);
                          }
                      }
                  }
                  else if (resource === 'configurationItems') {
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/cmdb_ci', {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/cmdb_ci', {}, qs);
                          }
                      }
                  }
                  else if (resource === 'department') {
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/cmn_department', {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/cmn_department', {}, qs);
                          }
                      }
                  }
                  else if (resource === 'dictionary') {
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/sys_dictionary', {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_dictionary', {}, qs);
                          }
                      }
                  }
                  else if (resource === 'incident') {
                      if (operation === 'create') {
                          const shortDescription = this.getNodeParameter('short_description', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const body = {
                              short_description: shortDescription,
                              ...additionalFields,
                          };
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'POST', '/now/table/incident', body);
                          responseData = response.result;
                      }
                      else if (operation === 'delete') {
                          const id = this.getNodeParameter('id', i);
                          responseData = await GenericFunctions_1.serviceNowApiRequest.call(this, 'DELETE', `/now/table/incident/${id}`);
                          responseData = { success: true };
                      }
                      else if (operation === 'get') {
                          const id = this.getNodeParameter('id', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', `/now/table/incident/${id}`, {}, qs);
                          responseData = response.result;
                      }
                      else if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/incident', {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/incident', {}, qs);
                          }
                      }
                      else if (operation === 'update') {
                          const id = this.getNodeParameter('id', i);
                          const body = this.getNodeParameter('updateFields', i);
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'PATCH', `/now/table/incident/${id}`, body);
                          responseData = response.result;
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i });
                      }
                  }
                  else if (resource === 'tableRecord') {
                      if (operation === 'create') {
                          const tableName = this.getNodeParameter('tableName', i);
                          const dataToSend = this.getNodeParameter('dataToSend', i);
                          let body = {};
                          if (dataToSend === 'mapInput') {
                              const inputsToIgnore = this.getNodeParameter('inputsToIgnore', i)
                                  .split(',')
                                  .map((field) => field.trim());
                              body = Object.entries(items[i].json)
                                  .filter(([key]) => !inputsToIgnore.includes(key))
                                  .reduce((obj, [key, val]) => Object.assign(obj, { [key]: val }), {});
                          }
                          else if (dataToSend === 'columns') {
                              const fieldsToSend = this.getNodeParameter('fieldsToSend', i);
                              body = fieldsToSend.field.reduce((obj, field) => {
                                  obj[field.column] = field.value;
                                  return obj;
                              }, {});
                          }
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'POST', `/now/table/${tableName}`, body);
                          responseData = response.result;
                      }
                      else if (operation === 'delete') {
                          const tableName = this.getNodeParameter('tableName', i);
                          const id = this.getNodeParameter('id', i);
                          responseData = await GenericFunctions_1.serviceNowApiRequest.call(this, 'DELETE', `/now/table/${tableName}/${id}`);
                          responseData = { success: true };
                      }
                      else if (operation === 'get') {
                          const tableName = this.getNodeParameter('tableName', i);
                          const id = this.getNodeParameter('id', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', `/now/table/${tableName}/${id}`, {}, qs);
                          responseData = response.result;
                      }
                      else if (operation === 'getAll') {
                          const tableName = this.getNodeParameter('tableName', i);
                          const returnAll = this.getNodeParameter('returnAll', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', `/now/table/${tableName}`, {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', `/now/table/${tableName}`, {}, qs);
                          }
                      }
                      else if (operation === 'update') {
                          const tableName = this.getNodeParameter('tableName', i);
                          const id = this.getNodeParameter('id', i);
                          const dataToSend = this.getNodeParameter('dataToSend', i);
                          let body = {};
                          if (dataToSend === 'mapInput') {
                              const inputsToIgnore = this.getNodeParameter('inputsToIgnore', i)
                                  .split(',')
                                  .map((field) => field.trim());
                              body = Object.entries(items[i].json)
                                  .filter(([key]) => !inputsToIgnore.includes(key))
                                  .reduce((obj, [key, val]) => Object.assign(obj, { [key]: val }), {});
                          }
                          else if (dataToSend === 'columns') {
                              const fieldsToSend = this.getNodeParameter('fieldsToSend', i);
                              body = fieldsToSend.field.reduce((obj, field) => {
                                  obj[field.column] = field.value;
                                  return obj;
                              }, {});
                          }
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'PATCH', `/now/table/${tableName}/${id}`, body);
                          responseData = response.result;
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i });
                      }
                  }
                  else if (resource === 'user') {
                      if (operation === 'create') {
                          const body = this.getNodeParameter('additionalFields', i);
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'POST', '/now/table/sys_user', body);
                          responseData = response.result;
                      }
                      else if (operation === 'delete') {
                          const id = this.getNodeParameter('id', i);
                          responseData = await GenericFunctions_1.serviceNowApiRequest.call(this, 'DELETE', `/now/table/sys_user/${id}`);
                          responseData = { success: true };
                      }
                      else if (operation === 'get') {
                          const getOption = this.getNodeParameter('getOption', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (getOption === 'id') {
                              const id = this.getNodeParameter('id', i);
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', `/now/table/sys_user/${id}`, {}, qs);
                              responseData = response.result;
                          }
                          else {
                              const userName = this.getNodeParameter('user_name', i);
                              qs.sysparm_query = `user_name=${userName}`;
                              qs.sysparm_limit = 1;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/sys_user', {}, qs);
                              responseData = response.result;
                          }
                      }
                      else if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/sys_user', {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user', {}, qs);
                          }
                      }
                      else if (operation === 'update') {
                          const id = this.getNodeParameter('id', i);
                          const body = this.getNodeParameter('updateFields', i);
                          const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'PATCH', `/now/table/sys_user/${id}`, body);
                          responseData = response.result;
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i });
                      }
                  }
                  else if (resource === 'userGroup') {
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/sys_user_group', {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user_group', {}, qs);
                          }
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i });
                      }
                  }
                  else if (resource === 'userRole') {
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          qs = this.getNodeParameter('options', i);
                          if (qs.sysparm_fields && typeof qs.sysparm_fields !== 'string') {
                              qs.sysparm_fields = qs.sysparm_fields.join(',');
                          }
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              qs.sysparm_limit = limit;
                              const response = await GenericFunctions_1.serviceNowApiRequest.call(this, 'GET', '/now/table/sys_user_role', {}, qs);
                              responseData = response.result;
                          }
                          else {
                              responseData = await GenericFunctions_1.serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user_role', {}, qs);
                          }
                      }
                      else {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i });
                      }
                  }
                  else {
                      throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, {
                          itemIndex: i,
                      });
                  }
              }
              catch (error) {
                  if (this.continueOnFail()) {
                      const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                      returnData.push(...executionErrorData);
                      continue;
                  }
                  throw error;
              }
              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
              returnData.push(...executionData);
          }
          if (resource === 'attachment') {
              if (operation === 'get' || operation === 'getAll') {
                  return [returnData];
              }
          }
          return [returnData];
      }
  }
  exports.ServiceNow = ServiceNow;
  //# sourceMappingURL=ServiceNow.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: ServiceNow node documentation
  description: Learn how to use the ServiceNow node in n8n. Follow technical documentation to integrate ServiceNow node into your workflows.
  contentType: [integration, reference]
  ---

  # ServiceNow node

  Use the ServiceNow node to automate work in ServiceNow, and integrate ServiceNow with other applications. n8n has built-in support for a wide range of ServiceNow features, including getting business services, departments, configuration items, and dictionary as well as creating, updating, and deleting incidents, users, and table records. 

  On this page, you'll find a list of operations the ServiceNow node supports and links to more resources.

  /// note | Credentials
  Refer to [ServiceNow credentials](/integrations/builtin/credentials/servicenow.md) for guidance on setting up authentication. 
  ///

  ## Operations

  * Business Service
      * Get All
  * Configuration Items
      * Get All
  * Department
      * Get All
  * Dictionary
      * Get All
  * Incident
      * Create
      * Delete
      * Get
      * Get All
      * Update
  * Table Record
      * Create
      * Delete
      * Get
      * Get All
      * Update
  * User
      * Create
      * Delete
      * Get
      * Get All
      * Update
  * User Group
      * Get All
  * User Role
      * Get All

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'servicenow') ]]

  --8<-- "_snippets/integrations/builtin/app-nodes/operation-not-supported.md"

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"49d863b7-b8e4-4fc5-9aae-894f96a7a656","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"2c21ba278fbab5e42f9b4fcd7d341843aa031e9a43a93d67091e7357bc963b31"}}


node_type: n8n-nodes-base.Signl4
name: Signl4
display_name: SIGNL4
description: Consume SIGNL4 API
category: transform
icon: file:signl4.png
code_hash: ecc751791e5a3ffc499f7d9a5a93314a13ff96290453d6af4f1d3438f6f0bf80
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.signl4
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 09:18:28
updated_at: 2025-06-08 09:18:28
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Signl4 = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const GenericFunctions_1 = require("./GenericFunctions");
  class Signl4 {
      constructor() {
          this.description = {
              displayName: 'SIGNL4',
              name: 'signl4',
              icon: 'file:signl4.png',
              group: ['transform'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume SIGNL4 API',
              defaults: {
                  name: 'SIGNL4',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'signl4Api',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Alert',
                              value: 'alert',
                          },
                      ],
                      default: 'alert',
                  },
                  {
                      displayName: 'Operation',
                      name: 'operation',
                      type: 'options',
                      noDataExpression: true,
                      displayOptions: {
                          show: {
                              resource: ['alert'],
                          },
                      },
                      options: [
                          {
                              name: 'Send',
                              value: 'send',
                              description: 'Send an alert',
                              action: 'Send an alert',
                          },
                          {
                              name: 'Resolve',
                              value: 'resolve',
                              description: 'Resolve an alert',
                              action: 'Resolve an alert',
                          },
                      ],
                      default: 'send',
                  },
                  {
                      displayName: 'Message',
                      name: 'message',
                      type: 'string',
                      default: '',
                      displayOptions: {
                          show: {
                              operation: ['send'],
                              resource: ['alert'],
                          },
                      },
                      description: 'A more detailed description for the alert',
                  },
                  {
                      displayName: 'Additional Fields',
                      name: 'additionalFields',
                      type: 'collection',
                      placeholder: 'Add Field',
                      displayOptions: {
                          show: {
                              operation: ['send'],
                              resource: ['alert'],
                          },
                      },
                      default: {},
                      options: [
                          {
                              displayName: 'Alerting Scenario',
                              name: 'alertingScenario',
                              type: 'options',
                              options: [
                                  {
                                      name: 'Single ACK',
                                      value: 'single_ack',
                                      description: 'In case only one person needs to confirm this Signl',
                                  },
                                  {
                                      name: 'Multi ACK',
                                      value: 'multi_ack',
                                      description: 'In case this alert must be confirmed by the number of people who are on duty at the time this Singl is raised',
                                  },
                              ],
                              default: 'single_ack',
                          },
                          {
                              displayName: 'Attachments',
                              name: 'attachmentsUi',
                              placeholder: 'Add Attachments',
                              type: 'fixedCollection',
                              typeOptions: {
                                  multipleValues: false,
                              },
                              options: [
                                  {
                                      name: 'attachmentsBinary',
                                      displayName: 'Attachments Binary',
                                      values: [
                                          {
                                              displayName: 'Property Name',
                                              name: 'property',
                                              type: 'string',
                                              placeholder: 'data',
                                              default: '',
                                              description: 'Name of the binary properties which contain data which should be added as attachment',
                                          },
                                      ],
                                  },
                              ],
                              default: {},
                          },
                          {
                              displayName: 'External ID',
                              name: 'externalId',
                              type: 'string',
                              default: '',
                              description: 'If the event originates from a record in a 3rd party system, use this parameter to pass the unique ID of that record. That ID will be communicated in outbound webhook notifications from SIGNL4, which is great for correlation/synchronization of that record with the alert. If you resolve / close an alert you must use the same External ID as in the original alert.',
                          },
                          {
                              displayName: 'Filtering',
                              name: 'filtering',
                              type: 'boolean',
                              default: false,
                              description: 'Whether to apply event filtering for this event, or not. If set to true, the event will only trigger a notification to the team, if it contains at least one keyword from one of your services and system categories (i.e. it is whitelisted)',
                          },
                          {
                              displayName: 'Location',
                              name: 'locationFieldsUi',
                              type: 'fixedCollection',
                              placeholder: 'Add Location',
                              default: {},
                              description: "Transmit location information ('latitude, longitude') with your event and display a map in the mobile app",
                              options: [
                                  {
                                      name: 'locationFieldsValues',
                                      displayName: 'Location',
                                      values: [
                                          {
                                              displayName: 'Latitude',
                                              name: 'latitude',
                                              type: 'string',
                                              required: true,
                                              description: 'The location latitude',
                                              default: '',
                                          },
                                          {
                                              displayName: 'Longitude',
                                              name: 'longitude',
                                              type: 'string',
                                              required: true,
                                              description: 'The location longitude',
                                              default: '',
                                          },
                                      ],
                                  },
                              ],
                          },
                          {
                              displayName: 'Service',
                              name: 'service',
                              type: 'string',
                              default: '',
                              description: 'Assigns the alert to the service/system category with the specified name',
                          },
                          {
                              displayName: 'Title',
                              name: 'title',
                              type: 'string',
                              default: '',
                              description: 'The title or subject of this alert',
                          },
                      ],
                  },
                  {
                      displayName: 'External ID',
                      name: 'externalId',
                      type: 'string',
                      default: '',
                      displayOptions: {
                          show: {
                              operation: ['resolve'],
                              resource: ['alert'],
                          },
                      },
                      description: 'If the event originates from a record in a 3rd party system, use this parameter to pass the unique ID of that record. That ID will be communicated in outbound webhook notifications from SIGNL4, which is great for correlation/synchronization of that record with the alert. If you resolve / close an alert you must use the same External ID as in the original alert.',
                  },
              ],
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          const length = items.length;
          let responseData;
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          for (let i = 0; i < length; i++) {
              try {
                  if (resource === 'alert') {
                      if (operation === 'send') {
                          const message = this.getNodeParameter('message', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const data = {
                              message,
                          };
                          if (additionalFields.title) {
                              data.title = additionalFields.title;
                          }
                          if (additionalFields.service) {
                              data.service = additionalFields.service;
                          }
                          if (additionalFields.locationFieldsUi) {
                              const locationUi = additionalFields.locationFieldsUi
                                  .locationFieldsValues;
                              if (locationUi) {
                                  data['X-S4-Location'] = `${locationUi.latitude},${locationUi.longitude}`;
                              }
                          }
                          if (additionalFields.alertingScenario) {
                              data['X-S4-AlertingScenario'] = additionalFields.alertingScenario;
                          }
                          if (additionalFields.filtering) {
                              data['X-S4-Filtering'] = additionalFields.filtering.toString();
                          }
                          if (additionalFields.externalId) {
                              data['X-S4-ExternalID'] = additionalFields.externalId;
                          }
                          data['X-S4-Status'] = 'new';
                          data['X-S4-SourceSystem'] = 'n8n';
                          const attachments = additionalFields.attachmentsUi;
                          if (attachments === null || attachments === void 0 ? void 0 : attachments.attachmentsBinary) {
                              const propertyName = attachments.attachmentsBinary
                                  .property;
                              const binaryData = this.helpers.assertBinaryData(i, propertyName);
                              if (binaryData) {
                                  const supportedFileExtension = ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'mp3', 'wav'];
                                  if (!supportedFileExtension.includes(binaryData.fileExtension)) {
                                      throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid extension, just ${supportedFileExtension.join(',')} are supported}`, { itemIndex: i });
                                  }
                                  const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, propertyName);
                                  data.attachment = {
                                      value: binaryDataBuffer,
                                      options: {
                                          filename: binaryData.fileName,
                                          contentType: binaryData.mimeType,
                                      },
                                  };
                              }
                          }
                          responseData = await GenericFunctions_1.SIGNL4ApiRequest.call(this, 'POST', '', {}, {
                              formData: data,
                          });
                      }
                      if (operation === 'resolve') {
                          const data = {};
                          data['X-S4-ExternalID'] = this.getNodeParameter('externalId', i);
                          data['X-S4-Status'] = 'resolved';
                          data['X-S4-SourceSystem'] = 'n8n';
                          responseData = await GenericFunctions_1.SIGNL4ApiRequest.call(this, 'POST', '', {}, {
                              formData: data,
                          });
                      }
                  }
                  if (Array.isArray(responseData)) {
                      returnData.push.apply(returnData, responseData);
                  }
                  else if (responseData !== undefined) {
                      returnData.push(responseData);
                  }
              }
              catch (error) {
                  if (this.continueOnFail()) {
                      returnData.push({ error: error.message });
                      continue;
                  }
                  throw error;
              }
          }
          return [this.helpers.returnJsonArray(returnData)];
      }
  }
  exports.Signl4 = Signl4;
  //# sourceMappingURL=Signl4.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: SIGNL4 node documentation
  description: Learn how to use the SIGNL4 node in n8n. Follow technical documentation to integrate SIGNL4 node into your workflows.
  contentType: [integration, reference]
  ---

  # SIGNL4 node

  Use the SIGNL4 node to automate work in SIGNL4, and integrate SIGNL4 with other applications. n8n supports sending and resolving alerts with SIGNL4.

  On this page, you'll find a list of operations the SIGNL4 node supports and links to more resources.

  /// note | Credentials
  Refer to [SIGNL4 credentials](/integrations/builtin/credentials/signl4.md) for guidance on setting up authentication. 
  ///

  ## Operations

  * Alert
      * Send an alert
      * Resolve an alert

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'signl4') ]]

example_workflow:
  {"nodes":[{"parameters":{},"type":"n8n-nodes-base.node","typeVersion":1,"position":[220,120],"id":"3b0ad024-1eaf-4c89-8d12-0bb71914fa1c","name":"Node"}],"connections":{"Node":{"main":[[]]}},"pinData":{},"meta":{"templateCredsSetupCompleted":true,"instanceId":"9c9e33a955e3d5965dceee51f42ea02cb1e2d6dc8367038281abe7d163b0ae1c"}}


