UNPKG

n8n-nodes-base

Version:

Base nodes of n8n

1,033 lines (1,032 loc) 133 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HubspotV1 = void 0; const change_case_1 = require("change-case"); const n8n_workflow_1 = require("n8n-workflow"); const CompanyDescription_1 = require("./CompanyDescription"); const ContactDescription_1 = require("./ContactDescription"); const ContactListDescription_1 = require("./ContactListDescription"); const DealDescription_1 = require("./DealDescription"); const EngagementDescription_1 = require("./EngagementDescription"); const FormDescription_1 = require("./FormDescription"); const GenericFunctions_1 = require("./GenericFunctions"); const TicketDescription_1 = require("./TicketDescription"); class HubspotV1 { description; constructor(baseDescription) { this.description = { ...baseDescription, group: ['output'], version: 1, subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', defaults: { name: 'HubSpot', }, inputs: [n8n_workflow_1.NodeConnectionTypes.Main], outputs: [n8n_workflow_1.NodeConnectionTypes.Main], credentials: [ { name: 'hubspotApi', required: true, testedBy: 'hubspotApiTest', displayOptions: { show: { authentication: ['apiKey'], }, }, }, { name: 'hubspotAppToken', required: true, testedBy: 'hubspotApiTest', displayOptions: { show: { authentication: ['appToken'], }, }, }, { name: 'hubspotOAuth2Api', required: true, displayOptions: { show: { authentication: ['oAuth2'], }, }, }, ], properties: [ { displayName: 'Authentication', name: 'authentication', type: 'options', options: [ { name: 'API Key', value: 'apiKey', }, { name: 'APP Token', value: 'appToken', }, { name: 'OAuth2', value: 'oAuth2', }, ], default: 'apiKey', }, { displayName: 'Resource', name: 'resource', type: 'options', noDataExpression: true, options: [ { name: 'Company', value: 'company', }, { name: 'Contact', value: 'contact', }, { name: 'Contact List', value: 'contactList', }, { name: 'Deal', value: 'deal', }, { name: 'Engagement', value: 'engagement', }, { name: 'Form', value: 'form', }, { name: 'Ticket', value: 'ticket', }, ], default: 'deal', }, // CONTACT ...ContactDescription_1.contactOperations, ...ContactDescription_1.contactFields, // CONTACT LIST ...ContactListDescription_1.contactListOperations, ...ContactListDescription_1.contactListFields, // COMPANY ...CompanyDescription_1.companyOperations, ...CompanyDescription_1.companyFields, // DEAL ...DealDescription_1.dealOperations, ...DealDescription_1.dealFields, // ENGAGEMENT ...EngagementDescription_1.engagementOperations, ...EngagementDescription_1.engagementFields, // FORM ...FormDescription_1.formOperations, ...FormDescription_1.formFields, // TICKET ...TicketDescription_1.ticketOperations, ...TicketDescription_1.ticketFields, ], }; } methods = { credentialTest: { async hubspotApiTest(credential) { try { await GenericFunctions_1.validateCredentials.call(this, credential.data); } catch (error) { const err = error; if (err.statusCode === 401) { return { status: 'Error', message: 'Invalid credentials', }; } } return { status: 'OK', message: 'Authentication successful', }; }, }, loadOptions: { /* -------------------------------------------------------------------------- */ /* CONTACT */ /* -------------------------------------------------------------------------- */ // Get all the contact lead statuses to display them to user so that they can // select them easily async getContactLeadStatuses() { const returnData = []; const endpoint = '/properties/v2/contacts/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.name === 'hs_lead_status') { for (const option of property.options) { const statusName = option.label; const statusId = option.value; returnData.push({ name: statusName, value: statusId, }); } } } return returnData; }, // Get all the contact legal basics to display them to user so that they can // select them easily async getContactLealBasics() { const returnData = []; const endpoint = '/properties/v2/contacts/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.name === 'hs_legal_basis') { for (const option of property.options) { const statusName = option.label; const statusId = option.value; returnData.push({ name: statusName, value: statusId, }); } } } return returnData; }, // Get all the contact lifecycle stages to display them to user so that they can // select them easily async getContactLifeCycleStages() { const returnData = []; const endpoint = '/properties/v2/contacts/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.name === 'lifecyclestage') { for (const option of property.options) { const stageName = option.label; const stageId = option.value; returnData.push({ name: stageName, value: stageId, }); } } } return returnData; }, // Get all the contact lifecycle stages to display them to user so that they can // select them easily async getContactOriginalSources() { const returnData = []; const endpoint = '/properties/v2/contacts/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.name === 'hs_analytics_source') { for (const option of property.options) { const sourceName = option.label; const sourceId = option.value; returnData.push({ name: sourceName, value: sourceId, }); } } } return returnData; }, // Get all the contact preffered languages to display them to user so that they can // select them easily async getContactPrefferedLanguages() { const returnData = []; const endpoint = '/properties/v2/contacts/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.name === 'hs_language') { for (const option of property.options) { const languageName = option.label; const languageId = option.value; returnData.push({ name: languageName, value: languageId, }); } } } return returnData; }, // Get all the contact preffered languages to display them to user so that they can // select them easily async getContactStatuses() { const returnData = []; const endpoint = '/properties/v2/contacts/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.name === 'hs_content_membership_status') { for (const option of property.options) { const languageName = option.label; const languageId = option.value; returnData.push({ name: languageName, value: languageId, }); } } } return returnData; }, // Get all the contact properties to display them to user so that they can // select them easily async getContactProperties() { const returnData = []; const endpoint = '/properties/v2/contacts/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { const propertyName = property.label; const propertyId = property.name; returnData.push({ name: propertyName, value: propertyId, }); } return returnData; }, // Get all the contact properties to display them to user so that they can // select them easily async getContactCustomProperties() { const returnData = []; const endpoint = '/properties/v2/contacts/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.hubspotDefined === null) { const propertyName = property.label; const propertyId = property.name; returnData.push({ name: propertyName, value: propertyId, }); } } return returnData; }, // Get all the contact number of employees options to display them to user so that they can // select them easily async getContactNumberOfEmployees() { const returnData = []; const endpoint = '/properties/v2/contacts/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.name === 'numemployees') { for (const option of property.options) { const optionName = option.label; const optionId = option.value; returnData.push({ name: optionName, value: optionId, }); } } } return returnData; }, /* -------------------------------------------------------------------------- */ /* COMPANY */ /* -------------------------------------------------------------------------- */ // Get all the company industries to display them to user so that they can // select them easily async getCompanyIndustries() { const returnData = []; const endpoint = '/properties/v2/companies/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.name === 'industry') { for (const option of property.options) { const industryName = option.label; const industryId = option.value; returnData.push({ name: industryName, value: industryId, }); } } } return returnData; }, // Get all the company lead statuses to display them to user so that they can // select them easily async getCompanyleadStatuses() { const returnData = []; const endpoint = '/properties/v2/companies/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.name === 'hs_lead_status') { for (const option of property.options) { const statusName = option.label; const statusId = option.value; returnData.push({ name: statusName, value: statusId, }); } } } return returnData; }, // Get all the company lifecycle stages to display them to user so that they can // select them easily async getCompanylifecycleStages() { const returnData = []; const endpoint = '/properties/v2/companies/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.name === 'lifecyclestage') { for (const option of property.options) { const stageName = option.label; const stageId = option.value; returnData.push({ name: stageName, value: stageId, }); } } } return returnData; }, // Get all the company types stages to display them to user so that they can // select them easily async getCompanyTypes() { const returnData = []; const endpoint = '/properties/v2/companies/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.name === 'type') { for (const option of property.options) { const typeName = option.label; const typeId = option.value; returnData.push({ name: typeName, value: typeId, }); } } } return returnData; }, // Get all the company types stages to display them to user so that they can // select them easily async getCompanyTargetAccounts() { const returnData = []; const endpoint = '/properties/v2/companies/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.name === 'hs_target_account') { for (const option of property.options) { const targetName = option.label; const targetId = option.value; returnData.push({ name: targetName, value: targetId, }); } } } return returnData; }, // Get all the company source types stages to display them to user so that they can // select them easily async getCompanySourceTypes() { const returnData = []; const endpoint = '/properties/v2/companies/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.name === 'hs_analytics_source') { for (const option of property.options) { const typeName = option.label; const typeId = option.value; returnData.push({ name: typeName, value: typeId, }); } } } return returnData; }, // Get all the company web technologies stages to display them to user so that they can // select them easily async getCompanyWebTechnologies() { const returnData = []; const endpoint = '/properties/v2/companies/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.name === 'web_technologies') { for (const option of property.options) { const technologyName = option.label; const technologyId = option.value; returnData.push({ name: technologyName, value: technologyId, }); } } } return returnData; }, // Get all the company properties to display them to user so that they can // select them easily async getCompanyProperties() { const returnData = []; const endpoint = '/properties/v2/companies/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { const propertyName = property.label; const propertyId = property.name; returnData.push({ name: propertyName, value: propertyId, }); } return returnData; }, // Get all the company custom properties to display them to user so that they can // select them easily async getCompanyCustomProperties() { const returnData = []; const endpoint = '/properties/v2/companies/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.hubspotDefined === null) { const propertyName = property.label; const propertyId = property.name; returnData.push({ name: propertyName, value: propertyId, }); } } return returnData; }, /* -------------------------------------------------------------------------- */ /* DEAL */ /* -------------------------------------------------------------------------- */ // Get all the groups to display them to user so that they can // select them easily async getDealStages() { const returnData = []; const endpoint = '/crm-pipelines/v1/pipelines/deals'; let stages = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); stages = stages.results[0].stages; for (const stage of stages) { const stageName = stage.label; const stageId = stage.stageId; returnData.push({ name: stageName, value: stageId, }); } return returnData; }, // Get all the deal types to display them to user so that they can // select them easily async getDealTypes() { const returnData = []; const endpoint = '/properties/v1/deals/properties/named/dealtype'; const dealTypes = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint); for (const dealType of dealTypes.options) { const dealTypeName = dealType.label; const dealTypeId = dealType.value; returnData.push({ name: dealTypeName, value: dealTypeId, }); } return returnData; }, // Get all the deal properties to display them to user so that they can // select them easily async getDealCustomProperties() { const returnData = []; const endpoint = '/properties/v2/deals/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.hubspotDefined === null) { const propertyName = property.label; const propertyId = property.name; returnData.push({ name: propertyName, value: propertyId, }); } } return returnData; }, // Get all the deal properties to display them to user so that they can // select them easily async getDealProperties() { const returnData = []; const endpoint = '/properties/v2/deals/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { const propertyName = property.label; const propertyId = property.name; returnData.push({ name: propertyName, value: propertyId, }); } return returnData; }, /* -------------------------------------------------------------------------- */ /* FORM */ /* -------------------------------------------------------------------------- */ // Get all the forms to display them to user so that they can // select them easily async getForms() { const returnData = []; const endpoint = '/forms/v2/forms'; const forms = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}, { formTypes: 'ALL' }); for (const form of forms) { const formName = form.name; const formId = form.guid; returnData.push({ name: formName, value: formId, }); } return returnData; }, // Get all the subscription types to display them to user so that they can // select them easily async getSubscriptionTypes() { const returnData = []; const endpoint = '/email/public/v1/subscriptions'; const subscriptions = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'subscriptionDefinitions', 'GET', endpoint, {}); for (const subscription of subscriptions) { const subscriptionName = subscription.name; const subscriptionId = subscription.id; returnData.push({ name: subscriptionName, value: subscriptionId, }); } return returnData; }, /* -------------------------------------------------------------------------- */ /* TICKET */ /* -------------------------------------------------------------------------- */ // Get all the ticket categories to display them to user so that they can // select them easily async getTicketCategories() { const returnData = []; const endpoint = '/properties/v2/tickets/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.name === 'hs_ticket_category') { for (const option of property.options) { const categoryName = option.label; const categoryId = option.value; returnData.push({ name: categoryName, value: categoryId, }); } } } return returnData.sort((a, b) => (a.name < b.name ? 0 : 1)); }, // Get all the ticket pipelines to display them to user so that they can // select them easily async getTicketPipelines() { const returnData = []; const endpoint = '/crm-pipelines/v1/pipelines/tickets'; const { results } = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const pipeline of results) { const pipelineName = pipeline.label; const pipelineId = pipeline.pipelineId; returnData.push({ name: pipelineName, value: pipelineId, }); } return returnData; }, // Get all the ticket resolutions to display them to user so that they can // select them easily async getTicketPriorities() { const returnData = []; const endpoint = '/properties/v2/tickets/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.name === 'hs_ticket_priority') { for (const option of property.options) { const priorityName = option.label; const priorityId = option.value; returnData.push({ name: priorityName, value: priorityId, }); } } } return returnData; }, // Get all the ticket properties to display them to user so that they can // select them easily async getTicketProperties() { const returnData = []; const endpoint = '/properties/v2/tickets/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { const propertyName = property.label; const propertyId = property.name; returnData.push({ name: propertyName, value: propertyId, }); } return returnData; }, // Get all the ticket resolutions to display them to user so that they can // select them easily async getTicketResolutions() { const returnData = []; const endpoint = '/properties/v2/tickets/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.name === 'hs_resolution') { for (const option of property.options) { const resolutionName = option.label; const resolutionId = option.value; returnData.push({ name: resolutionName, value: resolutionId, }); } } } return returnData.sort((a, b) => (a.name < b.name ? 0 : 1)); }, // Get all the ticket sources to display them to user so that they can // select them easily async getTicketSources() { const returnData = []; const endpoint = '/properties/v2/tickets/properties'; const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const property of properties) { if (property.name === 'source_type') { for (const option of property.options) { const sourceName = option.label; const sourceId = option.value; returnData.push({ name: sourceName, value: sourceId, }); } } } return returnData.sort((a, b) => (a.name < b.name ? 0 : 1)); }, // Get all the ticket stages to display them to user so that they can // select them easily async getTicketStages() { let currentPipelineId = this.getCurrentNodeParameter('pipelineId'); if (currentPipelineId === undefined) { currentPipelineId = this.getNodeParameter('updateFields.pipelineId', ''); } const returnData = []; const endpoint = '/crm-pipelines/v1/pipelines/tickets'; const { results } = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}); for (const pipeline of results) { if (currentPipelineId === pipeline.pipelineId) { for (const stage of pipeline.stages) { const stageName = stage.label; const stageId = stage.stageId; returnData.push({ name: stageName, value: stageId, }); } } } return returnData; }, /* -------------------------------------------------------------------------- */ /* COMMON */ /* -------------------------------------------------------------------------- */ // Get all the owners to display them to user so that they can // select them easily async getOwners() { const returnData = []; const endpoint = '/crm/v3/owners'; const { results } = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint); for (const owner of results) { const ownerName = owner.email; const ownerId = isNaN(parseInt(owner.id)) ? owner.id : parseInt(owner.id); returnData.push({ name: ownerName, value: ownerId, }); } return returnData; }, // Get all the companies to display them to user so that they can // select them easily async getCompanies() { const returnData = []; const qs = { properties: ['name'], }; const endpoint = '/companies/v2/companies/paged'; const companies = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'companies', 'GET', endpoint, {}, qs); for (const company of companies) { const companyName = company.properties.name ? company.properties.name.value : company.companyId; const companyId = company.companyId; returnData.push({ name: companyName, value: companyId, }); } return returnData.sort((a, b) => (a.name < b.name ? 0 : 1)); }, // Get all the companies to display them to user so that they can // select them easily async getContacts() { const returnData = []; const endpoint = '/contacts/v1/lists/all/contacts/all'; const contacts = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'contacts', 'GET', endpoint); for (const contact of contacts) { const firstName = contact.properties?.firstname?.value || ''; const lastName = contact.properties?.lastname?.value || ''; const contactName = `${firstName} ${lastName}`; const contactId = contact.vid; returnData.push({ name: contactName, value: contactId, description: `Contact VID: ${contactId}`, }); } return returnData.sort((a, b) => (a.name < b.name ? 0 : 1)); }, }, }; 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); //https://legacydocs.hubspot.com/docs/methods/lists/contact-lists-overview if (resource === 'contactList') { try { //https://legacydocs.hubspot.com/docs/methods/lists/add_contact_to_list if (operation === 'add') { const listId = this.getNodeParameter('listId', 0); const by = this.getNodeParameter('by', 0); const body = { emails: [], vids: [] }; for (let i = 0; i < length; i++) { if (by === 'id') { const id = this.getNodeParameter('id', i); body.vids.push(parseInt(id, 10)); } else { const email = this.getNodeParameter('email', i); body.emails.push(email); } } responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'POST', `/contacts/v1/lists/${listId}/add`, body); } //https://legacydocs.hubspot.com/docs/methods/lists/remove_contact_from_list if (operation === 'remove') { const listId = this.getNodeParameter('listId', 0); const body = { vids: [] }; for (let i = 0; i < length; i++) { const id = this.getNodeParameter('id', i); body.vids.push(parseInt(id, 10)); } responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'POST', `/contacts/v1/lists/${listId}/remove`, body); returnData.push.apply(returnData, responseData); } } catch (error) { if (this.continueOnFail()) { returnData.push({ json: { error: error.message } }); } else { throw error; } } } else { for (let i = 0; i < length; i++) { try { //https://developers.hubspot.com/docs/methods/contacts/create_or_update if (resource === 'contact') { //https://developers.hubspot.com/docs/methods/companies/create_company if (operation === 'upsert') { const email = this.getNodeParameter('email', i); const resolveData = this.getNodeParameter('resolveData', i); const additionalFields = this.getNodeParameter('additionalFields', i); const body = []; if (additionalFields.annualRevenue) { body.push({ property: 'annualrevenue', value: additionalFields.annualRevenue.toString(), }); } if (additionalFields.city) { body.push({ property: 'city', value: additionalFields.city, }); } if (additionalFields.clickedFacebookAd) { body.push({ property: 'hs_facebook_ad_clicked', value: additionalFields.clickedFacebookAd, }); } if (additionalFields.closeDate) { body.push({ property: 'closedate', value: new Date(additionalFields.closeDate).getTime(), }); } if (additionalFields.companyName) { body.push({ property: 'company', value: additionalFields.companyName, }); } if (additionalFields.companySize) { body.push({ property: 'company_size', value: additionalFields.companySize, }); } if (additionalFields.description) { body.push({ property: 'description', value: additionalFields.description, }); } if (additionalFields.contactOwner) { body.push({ property: 'hubspot_owner_id', value: additionalFields.contactOwner, }); } if (additionalFields.country) { body.push({ property: 'country', value: additionalFields.country, }); } if (additionalFields.dateOfBirth) { body.push({ property: 'date_of_birth', value: additionalFields.dateOfBirth, }); } if (additionalFields.degree) { body.push({ property: 'degree', value: additionalFields.degree, }); } if (additionalFields.facebookClickId) { body.push({ property: 'hs_facebook_click_id', value: additionalFields.facebookClickId, }); } if (additionalFields.faxNumber) { body.push({ property: 'fax', value: additionalFields.faxNumber, }); } if (additionalFields.fieldOfStudy) { body.push({ property: 'field_of_study', value: additionalFields.fieldOfStudy, }); } if (additionalFields.firstName) { body.push({ property: 'firstname', value: additionalFields.firstName, }); } if (additionalFields.gender) { body.push({ property: 'gender', value: additionalFields.gender, }); } if (additionalFields.googleAdClickId) { body.push({ property: 'hs_google_click_id', value: additionalFields.googleAdClickId, }); } if (additionalFields.graduationDate) { body.push({ property: 'graduation_date', value: additionalFields.graduationDate, }); } if (additionalFields.industry) { body.push({ property: 'industry', value: additionalFields.industry, }); } if (additionalFields.jobFunction) { body.push({ property: 'job_function', value: additionalFields.jobFunction, }); } if (additionalFields.jobTitle) { body.push({ property: 'jobtitle', value: additionalFields.jobTitle, }); } if (additionalFields.lastName) { body.push({ property: 'lastname', value: additionalFields.lastName, }); } if (additionalFields.leadStatus) { body.push({ property: 'hs_lead_status', value: additionalFields.leadStatus, }); } if (additionalFields.processingContactData) { body.push({ property: 'hs_legal_basis', value: additionalFields.processingContactData, }); } if (additionalFields.lifeCycleStage) { body.push({ property: 'lifecyclestage', value: additionalFields.lifeCycleStage, }); } if (additionalFields.maritalStatus) { body.push({