From bb7519b94c3779d32d43520037be4102c102b16c Mon Sep 17 00:00:00 2001 From: Ankit Gupta Date: Fri, 7 Jun 2024 11:16:17 +0530 Subject: [PATCH 1/5] added depends_on conditions on salesforce actions --- .../destinations/salesforce/account/index.ts | 15 ++++++ .../destinations/salesforce/contact/index.ts | 15 ++++++ .../src/destinations/salesforce/lead/index.ts | 15 ++++++ .../salesforce/opportunity/index.ts | 51 +++++++++++++++++-- 4 files changed, 93 insertions(+), 3 deletions(-) diff --git a/packages/destination-actions/src/destinations/salesforce/account/index.ts b/packages/destination-actions/src/destinations/salesforce/account/index.ts index bbb84e11b9..4b71084592 100644 --- a/packages/destination-actions/src/destinations/salesforce/account/index.ts +++ b/packages/destination-actions/src/destinations/salesforce/account/index.ts @@ -34,6 +34,21 @@ const action: ActionDefinition = { type: 'string', default: { '@path': '$.traits.name' + }, + depends_on: { + match: 'any', + conditions: [ + { + fieldKey: 'operation', + operator: 'is', + value: 'create' + }, + { + fieldKey: 'operation', + operator: 'is', + value: 'upsert' + } + ] } }, account_number: { diff --git a/packages/destination-actions/src/destinations/salesforce/contact/index.ts b/packages/destination-actions/src/destinations/salesforce/contact/index.ts index 95df669ca0..768c859e4f 100644 --- a/packages/destination-actions/src/destinations/salesforce/contact/index.ts +++ b/packages/destination-actions/src/destinations/salesforce/contact/index.ts @@ -37,6 +37,21 @@ const action: ActionDefinition = { then: { '@path': '$.traits.last_name' }, else: { '@path': '$.properties.last_name' } } + }, + depends_on: { + match: 'any', + conditions: [ + { + fieldKey: 'operation', + operator: 'is', + value: 'create' + }, + { + fieldKey: 'operation', + operator: 'is', + value: 'upsert' + } + ] } }, first_name: { diff --git a/packages/destination-actions/src/destinations/salesforce/lead/index.ts b/packages/destination-actions/src/destinations/salesforce/lead/index.ts index be5aff7008..bdc87af008 100644 --- a/packages/destination-actions/src/destinations/salesforce/lead/index.ts +++ b/packages/destination-actions/src/destinations/salesforce/lead/index.ts @@ -50,6 +50,21 @@ const action: ActionDefinition = { then: { '@path': '$.traits.last_name' }, else: { '@path': '$.properties.last_name' } } + }, + depends_on: { + match: 'any', + conditions: [ + { + fieldKey: 'operation', + operator: 'is', + value: 'create' + }, + { + fieldKey: 'operation', + operator: 'is', + value: 'upsert' + } + ] } }, first_name: { diff --git a/packages/destination-actions/src/destinations/salesforce/opportunity/index.ts b/packages/destination-actions/src/destinations/salesforce/opportunity/index.ts index 9ec852e839..776db8b8b0 100644 --- a/packages/destination-actions/src/destinations/salesforce/opportunity/index.ts +++ b/packages/destination-actions/src/destinations/salesforce/opportunity/index.ts @@ -31,17 +31,62 @@ const action: ActionDefinition = { label: 'Close Date', description: 'Date when the opportunity is expected to close. Use yyyy-MM-dd format. **This is required to create an opportunity.**', - type: 'string' + type: 'string', + depends_on: { + match: 'any', + conditions: [ + { + fieldKey: 'operation', + operator: 'is', + value: 'create' + }, + { + fieldKey: 'operation', + operator: 'is', + value: 'upsert' + } + ] + } }, name: { label: 'Name', description: 'A name for the opportunity. **This is required to create an opportunity.**', - type: 'string' + type: 'string', + depends_on: { + match: 'any', + conditions: [ + { + fieldKey: 'operation', + operator: 'is', + value: 'create' + }, + { + fieldKey: 'operation', + operator: 'is', + value: 'upsert' + } + ] + } }, stage_name: { label: 'Stage Name', description: 'Current stage of the opportunity. **This is required to create an opportunity.**', - type: 'string' + type: 'string', + depends_on: { + match: 'any', + conditions: [ + { + fieldKey: 'operation', + operator: 'is', + value: 'create' + }, + { + fieldKey: 'operation', + operator: 'is', + value: 'upsert' + } + ] + } }, amount: { label: 'Amount', From c9722b5a77fe06ba1fafdacf489e2fe312cb7678 Mon Sep 17 00:00:00 2001 From: Ankit Gupta Date: Mon, 17 Jun 2024 14:31:59 +0530 Subject: [PATCH 2/5] updated conditions for depends_on fields --- .../destinations/salesforce/account/index.ts | 10 ++----- .../destinations/salesforce/contact/index.ts | 10 ++----- .../src/destinations/salesforce/lead/index.ts | 10 ++----- .../salesforce/opportunity/index.ts | 30 ++++--------------- 4 files changed, 12 insertions(+), 48 deletions(-) diff --git a/packages/destination-actions/src/destinations/salesforce/account/index.ts b/packages/destination-actions/src/destinations/salesforce/account/index.ts index 4b71084592..95fcb20b4d 100644 --- a/packages/destination-actions/src/destinations/salesforce/account/index.ts +++ b/packages/destination-actions/src/destinations/salesforce/account/index.ts @@ -36,17 +36,11 @@ const action: ActionDefinition = { '@path': '$.traits.name' }, depends_on: { - match: 'any', conditions: [ { fieldKey: 'operation', - operator: 'is', - value: 'create' - }, - { - fieldKey: 'operation', - operator: 'is', - value: 'upsert' + operator: 'is_not', + value: 'delete' } ] } diff --git a/packages/destination-actions/src/destinations/salesforce/contact/index.ts b/packages/destination-actions/src/destinations/salesforce/contact/index.ts index 768c859e4f..5ae8a81cc3 100644 --- a/packages/destination-actions/src/destinations/salesforce/contact/index.ts +++ b/packages/destination-actions/src/destinations/salesforce/contact/index.ts @@ -39,17 +39,11 @@ const action: ActionDefinition = { } }, depends_on: { - match: 'any', conditions: [ { fieldKey: 'operation', - operator: 'is', - value: 'create' - }, - { - fieldKey: 'operation', - operator: 'is', - value: 'upsert' + operator: 'is_not', + value: 'delete' } ] } diff --git a/packages/destination-actions/src/destinations/salesforce/lead/index.ts b/packages/destination-actions/src/destinations/salesforce/lead/index.ts index bdc87af008..b3960546ac 100644 --- a/packages/destination-actions/src/destinations/salesforce/lead/index.ts +++ b/packages/destination-actions/src/destinations/salesforce/lead/index.ts @@ -52,17 +52,11 @@ const action: ActionDefinition = { } }, depends_on: { - match: 'any', conditions: [ { fieldKey: 'operation', - operator: 'is', - value: 'create' - }, - { - fieldKey: 'operation', - operator: 'is', - value: 'upsert' + operator: 'is_not', + value: 'delete' } ] } diff --git a/packages/destination-actions/src/destinations/salesforce/opportunity/index.ts b/packages/destination-actions/src/destinations/salesforce/opportunity/index.ts index 776db8b8b0..a50a31fef5 100644 --- a/packages/destination-actions/src/destinations/salesforce/opportunity/index.ts +++ b/packages/destination-actions/src/destinations/salesforce/opportunity/index.ts @@ -33,17 +33,11 @@ const action: ActionDefinition = { 'Date when the opportunity is expected to close. Use yyyy-MM-dd format. **This is required to create an opportunity.**', type: 'string', depends_on: { - match: 'any', conditions: [ { fieldKey: 'operation', - operator: 'is', - value: 'create' - }, - { - fieldKey: 'operation', - operator: 'is', - value: 'upsert' + operator: 'is_not', + value: 'delete' } ] } @@ -53,17 +47,11 @@ const action: ActionDefinition = { description: 'A name for the opportunity. **This is required to create an opportunity.**', type: 'string', depends_on: { - match: 'any', conditions: [ { fieldKey: 'operation', - operator: 'is', - value: 'create' - }, - { - fieldKey: 'operation', - operator: 'is', - value: 'upsert' + operator: 'is_not', + value: 'delete' } ] } @@ -73,17 +61,11 @@ const action: ActionDefinition = { description: 'Current stage of the opportunity. **This is required to create an opportunity.**', type: 'string', depends_on: { - match: 'any', conditions: [ { fieldKey: 'operation', - operator: 'is', - value: 'create' - }, - { - fieldKey: 'operation', - operator: 'is', - value: 'upsert' + operator: 'is_not', + value: 'delete' } ] } From 86913c8d5307730312fcbb33f60fa8e1a522770f Mon Sep 17 00:00:00 2001 From: Ankit Gupta Date: Thu, 20 Jun 2024 09:00:33 +0530 Subject: [PATCH 3/5] Updated depends on condition for delete operation in salesforce actions --- .../destinations/salesforce/account/index.ts | 58 +++++++++++-------- .../destinations/salesforce/sf-properties.ts | 20 ++++++- 2 files changed, 50 insertions(+), 28 deletions(-) diff --git a/packages/destination-actions/src/destinations/salesforce/account/index.ts b/packages/destination-actions/src/destinations/salesforce/account/index.ts index 95fcb20b4d..b15579ffb0 100644 --- a/packages/destination-actions/src/destinations/salesforce/account/index.ts +++ b/packages/destination-actions/src/destinations/salesforce/account/index.ts @@ -10,7 +10,8 @@ import { validateLookup, enable_batching, recordMatcherOperator, - batch_size + batch_size, + hideIfDeleteOperation } from '../sf-properties' import type { Payload } from './generated-types' @@ -35,15 +36,7 @@ const action: ActionDefinition = { default: { '@path': '$.traits.name' }, - depends_on: { - conditions: [ - { - fieldKey: 'operation', - operator: 'is_not', - value: 'delete' - } - ] - } + depends_on: hideIfDeleteOperation }, account_number: { label: 'Account Number', @@ -52,7 +45,8 @@ const action: ActionDefinition = { type: 'string', default: { '@path': '$.groupId' - } + }, + depends_on: hideIfDeleteOperation }, number_of_employees: { label: 'Number of employees', @@ -64,7 +58,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.employees' }, else: { '@path': '$.properties.employees' } } - } + }, + depends_on: hideIfDeleteOperation }, billing_city: { label: 'Billing City', @@ -76,7 +71,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.address.city' }, else: { '@path': '$.properties.address.city' } } - } + }, + depends_on: hideIfDeleteOperation }, billing_postal_code: { label: 'Billing Postal Code', @@ -88,7 +84,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.address.postal_code' }, else: { '@path': '$.properties.address.postal_code' } } - } + }, + depends_on: hideIfDeleteOperation }, billing_country: { label: 'Billing Country', @@ -100,7 +97,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.address.country' }, else: { '@path': '$.properties.address.country' } } - } + }, + depends_on: hideIfDeleteOperation }, billing_street: { label: 'Billing Street', @@ -112,7 +110,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.address.street' }, else: { '@path': '$.properties.address.street' } } - } + }, + depends_on: hideIfDeleteOperation }, billing_state: { label: 'Billing State', @@ -124,32 +123,38 @@ const action: ActionDefinition = { then: { '@path': '$.traits.address.state' }, else: { '@path': '$.properties.address.state' } } - } + }, + depends_on: hideIfDeleteOperation }, shipping_city: { label: 'Shipping City', description: 'City for the shipping address of the account.', - type: 'string' + type: 'string', + depends_on: hideIfDeleteOperation }, shipping_postal_code: { label: 'Shipping Postal Code', description: 'Postal code for the shipping address of the account.', - type: 'string' + type: 'string', + depends_on: hideIfDeleteOperation }, shipping_country: { label: 'Shipping Country', description: 'Country for the shipping address of the account.', - type: 'string' + type: 'string', + depends_on: hideIfDeleteOperation }, shipping_street: { label: 'Shipping Street', description: 'Street address for the shipping address of the account.', - type: 'string' + type: 'string', + depends_on: hideIfDeleteOperation }, shipping_state: { label: 'Shipping State', description: 'State for the shipping address of the account.', - type: 'string' + type: 'string', + depends_on: hideIfDeleteOperation }, phone: { label: 'Phone', @@ -161,7 +166,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.phone' }, else: { '@path': '$.properties.phone' } } - } + }, + depends_on: hideIfDeleteOperation }, description: { label: 'Description', @@ -173,7 +179,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.description' }, else: { '@path': '$.properties.description' } } - } + }, + depends_on: hideIfDeleteOperation }, website: { label: 'Website', @@ -185,7 +192,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.website' }, else: { '@path': '$.properties.website' } } - } + }, + depends_on: hideIfDeleteOperation }, customFields: customFields }, diff --git a/packages/destination-actions/src/destinations/salesforce/sf-properties.ts b/packages/destination-actions/src/destinations/salesforce/sf-properties.ts index 442615b3cb..76094be1a0 100644 --- a/packages/destination-actions/src/destinations/salesforce/sf-properties.ts +++ b/packages/destination-actions/src/destinations/salesforce/sf-properties.ts @@ -1,4 +1,15 @@ import { IntegrationError, InputField } from '@segment/actions-core' +import { DependsOnConditions } from '@segment/actions-core/destination-kit/types' + +export const hideIfDeleteOperation: DependsOnConditions = { + conditions: [ + { + fieldKey: 'operation', + operator: 'is_not', + value: 'delete' + } + ] +} export const operation: InputField = { label: 'Operation', @@ -19,7 +30,8 @@ export const enable_batching: InputField = { description: 'If true, events are sent to [Salesforce’s Bulk API 2.0](https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/asynch_api_intro.htm) rather than their streaming REST API. Once enabled, Segment will collect events into batches of 5000 before sending to Salesforce. *Enabling Bulk API is not compatible with the `create` operation*.', type: 'boolean', - default: false + default: false, + depends_on: hideIfDeleteOperation } export const batch_size: InputField = { @@ -28,7 +40,8 @@ export const batch_size: InputField = { type: 'number', required: false, unsafe_hidden: true, - default: 5000 + default: 5000, + depends_on: hideIfDeleteOperation } export const bulkUpsertExternalId: InputField = { @@ -145,7 +158,8 @@ export const customFields: InputField = { `, type: 'object', - defaultObjectUI: 'keyvalue' + defaultObjectUI: 'keyvalue', + depends_on: hideIfDeleteOperation } interface Payload { From a8c0d0a3378421a3dedb67f8dc28c9f9fd06c6cc Mon Sep 17 00:00:00 2001 From: Ankit Gupta Date: Mon, 24 Jun 2024 22:21:23 +0530 Subject: [PATCH 4/5] Updated depends on conditions for salesforce actions Contact, lead, opportunity --- .../destinations/salesforce/contact/index.ts | 37 +++++++++--------- .../src/destinations/salesforce/lead/index.ts | 37 +++++++++--------- .../salesforce/opportunity/index.ts | 39 +++++-------------- 3 files changed, 47 insertions(+), 66 deletions(-) diff --git a/packages/destination-actions/src/destinations/salesforce/contact/index.ts b/packages/destination-actions/src/destinations/salesforce/contact/index.ts index 5ae8a81cc3..f3c1863c78 100644 --- a/packages/destination-actions/src/destinations/salesforce/contact/index.ts +++ b/packages/destination-actions/src/destinations/salesforce/contact/index.ts @@ -10,7 +10,8 @@ import { validateLookup, enable_batching, recordMatcherOperator, - batch_size + batch_size, + hideIfDeleteOperation } from '../sf-properties' import Salesforce, { generateSalesforceRequest } from '../sf-operations' @@ -38,15 +39,7 @@ const action: ActionDefinition = { else: { '@path': '$.properties.last_name' } } }, - depends_on: { - conditions: [ - { - fieldKey: 'operation', - operator: 'is_not', - value: 'delete' - } - ] - } + depends_on: hideIfDeleteOperation }, first_name: { label: 'First Name', @@ -58,13 +51,15 @@ const action: ActionDefinition = { then: { '@path': '$.traits.first_name' }, else: { '@path': '$.properties.first_name' } } - } + }, + depends_on: hideIfDeleteOperation }, account_id: { label: 'Account ID', description: 'The ID of the account that this contact is associated with. This is the Salesforce-generated ID assigned to the account during creation (i.e. 0018c00002CDThnAAH).', - type: 'string' + type: 'string', + depends_on: hideIfDeleteOperation }, email: { label: 'Email', @@ -76,7 +71,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.email' }, else: { '@path': '$.properties.email' } } - } + }, + depends_on: hideIfDeleteOperation }, mailing_city: { label: 'Mailing City', @@ -88,7 +84,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.address.city' }, else: { '@path': '$.properties.address.city' } } - } + }, + depends_on: hideIfDeleteOperation }, mailing_postal_code: { label: 'Mailing Postal Code', @@ -100,7 +97,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.address.postal_code' }, else: { '@path': '$.properties.address.postal_code' } } - } + }, + depends_on: hideIfDeleteOperation }, mailing_country: { label: 'Mailing Country', @@ -112,7 +110,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.address.country' }, else: { '@path': '$.properties.address.country' } } - } + }, + depends_on: hideIfDeleteOperation }, mailing_street: { label: 'Mailing Street', @@ -124,7 +123,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.address.street' }, else: { '@path': '$.properties.address.street' } } - } + }, + depends_on: hideIfDeleteOperation }, mailing_state: { label: 'Mailing State', @@ -136,7 +136,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.address.state' }, else: { '@path': '$.properties.address.state' } } - } + }, + depends_on: hideIfDeleteOperation }, customFields: customFields }, diff --git a/packages/destination-actions/src/destinations/salesforce/lead/index.ts b/packages/destination-actions/src/destinations/salesforce/lead/index.ts index b3960546ac..d7dede2ad6 100644 --- a/packages/destination-actions/src/destinations/salesforce/lead/index.ts +++ b/packages/destination-actions/src/destinations/salesforce/lead/index.ts @@ -10,7 +10,8 @@ import { validateLookup, enable_batching, recordMatcherOperator, - batch_size + batch_size, + hideIfDeleteOperation } from '../sf-properties' import Salesforce, { generateSalesforceRequest } from '../sf-operations' @@ -38,7 +39,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.company' }, else: { '@path': '$.properties.company' } } - } + }, + depends_on: hideIfDeleteOperation }, last_name: { label: 'Last Name', @@ -51,15 +53,7 @@ const action: ActionDefinition = { else: { '@path': '$.properties.last_name' } } }, - depends_on: { - conditions: [ - { - fieldKey: 'operation', - operator: 'is_not', - value: 'delete' - } - ] - } + depends_on: hideIfDeleteOperation }, first_name: { label: 'First Name', @@ -71,7 +65,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.first_name' }, else: { '@path': '$.properties.first_name' } } - } + }, + depends_on: hideIfDeleteOperation }, email: { label: 'Email', @@ -83,7 +78,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.email' }, else: { '@path': '$.properties.email' } } - } + }, + depends_on: hideIfDeleteOperation }, city: { label: 'City', @@ -95,7 +91,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.address.city' }, else: { '@path': '$.properties.address.city' } } - } + }, + depends_on: hideIfDeleteOperation }, postal_code: { label: 'Postal Code', @@ -107,7 +104,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.address.postal_code' }, else: { '@path': '$.properties.address.postal_code' } } - } + }, + depends_on: hideIfDeleteOperation }, country: { label: 'Country', @@ -119,7 +117,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.address.country' }, else: { '@path': '$.properties.address.country' } } - } + }, + depends_on: hideIfDeleteOperation }, street: { label: 'Street', @@ -131,7 +130,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.address.street' }, else: { '@path': '$.properties.address.street' } } - } + }, + depends_on: hideIfDeleteOperation }, state: { label: 'State', @@ -143,7 +143,8 @@ const action: ActionDefinition = { then: { '@path': '$.traits.address.state' }, else: { '@path': '$.properties.address.state' } } - } + }, + depends_on: hideIfDeleteOperation }, customFields: customFields }, diff --git a/packages/destination-actions/src/destinations/salesforce/opportunity/index.ts b/packages/destination-actions/src/destinations/salesforce/opportunity/index.ts index a50a31fef5..f59855cd1a 100644 --- a/packages/destination-actions/src/destinations/salesforce/opportunity/index.ts +++ b/packages/destination-actions/src/destinations/salesforce/opportunity/index.ts @@ -10,7 +10,8 @@ import { validateLookup, enable_batching, recordMatcherOperator, - batch_size + batch_size, + hideIfDeleteOperation } from '../sf-properties' import type { Payload } from './generated-types' @@ -32,53 +33,31 @@ const action: ActionDefinition = { description: 'Date when the opportunity is expected to close. Use yyyy-MM-dd format. **This is required to create an opportunity.**', type: 'string', - depends_on: { - conditions: [ - { - fieldKey: 'operation', - operator: 'is_not', - value: 'delete' - } - ] - } + depends_on: hideIfDeleteOperation }, name: { label: 'Name', description: 'A name for the opportunity. **This is required to create an opportunity.**', type: 'string', - depends_on: { - conditions: [ - { - fieldKey: 'operation', - operator: 'is_not', - value: 'delete' - } - ] - } + depends_on: hideIfDeleteOperation }, stage_name: { label: 'Stage Name', description: 'Current stage of the opportunity. **This is required to create an opportunity.**', type: 'string', - depends_on: { - conditions: [ - { - fieldKey: 'operation', - operator: 'is_not', - value: 'delete' - } - ] - } + depends_on: hideIfDeleteOperation }, amount: { label: 'Amount', description: 'Estimated total sale amount.', - type: 'string' + type: 'string', + depends_on: hideIfDeleteOperation }, description: { label: 'Description', description: 'A text description of the opportunity.', - type: 'string' + type: 'string', + depends_on: hideIfDeleteOperation }, customFields: customFields }, From 1df4a27eac9daca2ae3aebafe0e9da79af7bfb8b Mon Sep 17 00:00:00 2001 From: Ankit Gupta Date: Tue, 25 Jun 2024 11:44:33 +0530 Subject: [PATCH 5/5] Added depends on for cases action in salesforce --- .../src/destinations/salesforce/cases/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/destination-actions/src/destinations/salesforce/cases/index.ts b/packages/destination-actions/src/destinations/salesforce/cases/index.ts index 599688a95d..f3ab985619 100644 --- a/packages/destination-actions/src/destinations/salesforce/cases/index.ts +++ b/packages/destination-actions/src/destinations/salesforce/cases/index.ts @@ -10,7 +10,8 @@ import { validateLookup, enable_batching, recordMatcherOperator, - batch_size + batch_size, + hideIfDeleteOperation } from '../sf-properties' import Salesforce, { generateSalesforceRequest } from '../sf-operations' @@ -30,7 +31,8 @@ const action: ActionDefinition = { description: { label: 'Description', description: 'A text description of the case.', - type: 'string' + type: 'string', + depends_on: hideIfDeleteOperation }, customFields: customFields },