Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use destination definition name in place of string for custom object #3737

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/v0/destinations/salesforce/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ async function getSaleforceIdForRecord(
);
}
const searchRecord = processedsfSearchResponse.response?.searchRecords?.find(
(rec) => typeof identifierValue !== 'undefined' && rec[identifierType] === `${identifierValue}`,
(rec) =>
typeof identifierValue !== 'undefined' &&
// eslint-disable-next-line eqeqeq
rec[identifierType] == identifierValue,
);

return searchRecord?.Id;
Expand Down Expand Up @@ -190,8 +193,9 @@ async function getSalesforceIdFromPayload(
'Invalid externalId. id, type, identifierType must be provided',
);
}

const objectType = type.toLowerCase().replace('salesforce-', '');
const objectType = type
.toLowerCase()
.replace(`${destination.DestinationDefinition.Name.toLowerCase()}-`, '');
let salesforceId = id;

// Fetch the salesforce Id if the identifierType is not ID
Expand Down
60 changes: 56 additions & 4 deletions test/integrations/destinations/salesforce/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ const transformationMocksData = [
httpRes: {
status: 200,
data: {
access_token:
'00D2v000002lXbX!ARcAQJBSGNA1Rq.MbUdtmlREscrN_nO3ckBz6kc4jRQGxqAzNkhT1XZIF0yPqyCQSnezWO3osMw1ewpjToO7q41E9.LvedWY',
access_token: 'dummy.access.token',
instance_url: 'https://ap15.salesforce.com',
id: 'https://login.salesforce.com/id/00D2v000002lXbXEAU/0052v00000ga9WqAAI',
token_type: 'Bearer',
Expand All @@ -198,8 +197,7 @@ const transformationMocksData = [
httpRes: {
status: 200,
data: {
access_token:
'00D2v000002lXbX!ARcAQJBSGNA1Rq.MbUdtmlREscrN_nO3ckBz6kc4jRQGxqAzNkhT1XZIF0yPqyCQSnezWO3osMw1ewpjToO7q41E9.LvedWY',
access_token: 'dummy.access.token',
instance_url: 'https://ap15.salesforce.com',
id: 'https://login.salesforce.com/id/00D2v000002lXbXEAU/0052v00000ga9WqAAI',
token_type: 'Bearer',
Expand Down Expand Up @@ -245,6 +243,18 @@ const transformationMocksData = [
},
},
},
{
httpReq: {
url: 'https://ap15.salesforce.com/services/data/v50.0/parameterizedSearch/?q=72727&sobject=customobject&in=CustomObject__c&customobject.fields=id,CustomObject__c',
method: 'GET',
},
httpRes: {
status: 200,
data: {
searchRecords: [],
},
},
},
{
httpReq: {
url: 'https://ap15.salesforce.com/services/data/v50.0/parameterizedSearch/?q=peter.gibbons1%40initech.com&sobject=Lead&Lead.fields=id',
Expand All @@ -265,6 +275,48 @@ const transformationMocksData = [
},
},
},
{
httpReq: {
url: 'https://ap15.salesforce.com/services/data/v50.0/parameterizedSearch/?q=72728&sobject=customobject2&in=CustomObject2__c&customobject2.fields=id,CustomObject2__c',
method: 'GET',
},
httpRes: {
status: 200,
data: {
searchRecords: [
{
attributes: {
type: 'CustomObject2__c',
url: '/services/data/v50.0/CustomObject2__c/id1101',
},
Id: 'id1101',
CustomObject2__c: 72728,
},
],
},
},
},
{
httpReq: {
url: 'https://ap15.salesforce.com/services/data/v50.0/parameterizedSearch/?q=72729&sobject=customobject2&in=CustomObject2__c&customobject2.fields=id,CustomObject2__c',
method: 'GET',
},
httpRes: {
status: 200,
data: {
searchRecords: [
{
attributes: {
type: 'CustomObject2__c',
url: '/services/data/v50.0/CustomObject2__c/id1102',
},
Id: 'id1102',
CustomObject2__c: '72729',
},
],
},
},
},
{
httpReq: {
url: 'https://ap15.salesforce.com/services/data/v50.0/parameterizedSearch/?q=ddv_ua%2B%7B%7B1234*245%7D%7D%40bugFix.com&sobject=Lead&Lead.fields=id,IsConverted,ConvertedContactId,IsDeleted',
Expand Down
30 changes: 10 additions & 20 deletions test/integrations/destinations/salesforce/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ export const data = [
endpoint: 'https://ap15.salesforce.com/services/data/v50.0/sobjects/Lead',
headers: {
'Content-Type': 'application/json',
Authorization:
'Bearer 00D2v000002lXbX!ARcAQJBSGNA1Rq.MbUdtmlREscrN_nO3ckBz6kc4jRQGxqAzNkhT1XZIF0yPqyCQSnezWO3osMw1ewpjToO7q41E9.LvedWY',
Authorization: 'Bearer dummy.access.token',
Dismissed Show dismissed Hide dismissed
},
params: {},
body: {
Expand Down Expand Up @@ -225,8 +224,7 @@ export const data = [
endpoint: 'https://ap15.salesforce.com/services/data/v50.0/sobjects/Lead',
headers: {
'Content-Type': 'application/json',
Authorization:
'Bearer 00D2v000002lXbX!ARcAQJBSGNA1Rq.MbUdtmlREscrN_nO3ckBz6kc4jRQGxqAzNkhT1XZIF0yPqyCQSnezWO3osMw1ewpjToO7q41E9.LvedWY',
Authorization: 'Bearer dummy.access.token',
Dismissed Show dismissed Hide dismissed
},
params: {},
body: {
Expand Down Expand Up @@ -354,8 +352,7 @@ export const data = [
endpoint: 'https://ap15.salesforce.com/services/data/v50.0/sobjects/Lead',
headers: {
'Content-Type': 'application/json',
Authorization:
'Bearer 00D2v000002lXbX!ARcAQJBSGNA1Rq.MbUdtmlREscrN_nO3ckBz6kc4jRQGxqAzNkhT1XZIF0yPqyCQSnezWO3osMw1ewpjToO7q41E9.LvedWY',
Authorization: 'Bearer dummy.access.token',
Dismissed Show dismissed Hide dismissed
},
params: {},
body: {
Expand Down Expand Up @@ -591,8 +588,7 @@ export const data = [
endpoint: 'https://ap15.salesforce.com/services/data/v50.0/sobjects/Lead',
headers: {
'Content-Type': 'application/json',
Authorization:
'Bearer 00D2v000002lXbX!ARcAQJBSGNA1Rq.MbUdtmlREscrN_nO3ckBz6kc4jRQGxqAzNkhT1XZIF0yPqyCQSnezWO3osMw1ewpjToO7q41E9.LvedWY',
Authorization: 'Bearer dummy.access.token',
Dismissed Show dismissed Hide dismissed
},
params: {},
body: {
Expand Down Expand Up @@ -721,8 +717,7 @@ export const data = [
endpoint: 'https://ap15.salesforce.com/services/data/v50.0/sobjects/Lead',
headers: {
'Content-Type': 'application/json',
Authorization:
'Bearer 00D2v000002lXbX!ARcAQJBSGNA1Rq.MbUdtmlREscrN_nO3ckBz6kc4jRQGxqAzNkhT1XZIF0yPqyCQSnezWO3osMw1ewpjToO7q41E9.LvedWY',
Authorization: 'Bearer dummy.access.token',
Dismissed Show dismissed Hide dismissed
},
params: {},
body: {
Expand Down Expand Up @@ -855,8 +850,7 @@ export const data = [
'https://ap15.salesforce.com/services/data/v50.0/sobjects/Contact/sf-contact-id?_HttpMethod=PATCH',
headers: {
'Content-Type': 'application/json',
Authorization:
'Bearer 00D2v000002lXbX!ARcAQJBSGNA1Rq.MbUdtmlREscrN_nO3ckBz6kc4jRQGxqAzNkhT1XZIF0yPqyCQSnezWO3osMw1ewpjToO7q41E9.LvedWY',
Authorization: 'Bearer dummy.access.token',
Dismissed Show dismissed Hide dismissed
},
params: {},
body: {
Expand Down Expand Up @@ -989,8 +983,7 @@ export const data = [
'https://ap15.salesforce.com/services/data/v50.0/sobjects/Lead/sf-contact-id?_HttpMethod=PATCH',
headers: {
'Content-Type': 'application/json',
Authorization:
'Bearer 00D2v000002lXbX!ARcAQJBSGNA1Rq.MbUdtmlREscrN_nO3ckBz6kc4jRQGxqAzNkhT1XZIF0yPqyCQSnezWO3osMw1ewpjToO7q41E9.LvedWY',
Authorization: 'Bearer dummy.access.token',
Dismissed Show dismissed Hide dismissed
},
params: {},
userId: '',
Expand Down Expand Up @@ -1117,8 +1110,7 @@ export const data = [
endpoint: 'https://ap15.salesforce.com/services/data/v50.0/sobjects/Lead',
headers: {
'Content-Type': 'application/json',
Authorization:
'Bearer 00D2v000002lXbX!ARcAQJBSGNA1Rq.MbUdtmlREscrN_nO3ckBz6kc4jRQGxqAzNkhT1XZIF0yPqyCQSnezWO3osMw1ewpjToO7q41E9.LvedWY',
Authorization: 'Bearer dummy.access.token',
Dismissed Show dismissed Hide dismissed
},
params: {},
body: {
Expand Down Expand Up @@ -1244,8 +1236,7 @@ export const data = [
'https://ap15.salesforce.com/services/data/v50.0/sobjects/custom_object__c/a005g0000383kmUAAQ?_HttpMethod=PATCH',
headers: {
'Content-Type': 'application/json',
Authorization:
'Bearer 00D2v000002lXbX!ARcAQJBSGNA1Rq.MbUdtmlREscrN_nO3ckBz6kc4jRQGxqAzNkhT1XZIF0yPqyCQSnezWO3osMw1ewpjToO7q41E9.LvedWY',
Authorization: 'Bearer dummy.access.token',
Dismissed Show dismissed Hide dismissed
},
params: {},
body: {
Expand Down Expand Up @@ -1360,8 +1351,7 @@ export const data = [
'https://ap15.salesforce.com/services/data/v50.0/sobjects/custom_object__c/a005g0000383kmUAAQ?_HttpMethod=PATCH',
headers: {
'Content-Type': 'application/json',
Authorization:
'Bearer 00D2v000002lXbX!ARcAQJBSGNA1Rq.MbUdtmlREscrN_nO3ckBz6kc4jRQGxqAzNkhT1XZIF0yPqyCQSnezWO3osMw1ewpjToO7q41E9.LvedWY',
Authorization: 'Bearer dummy.access.token',
Dismissed Show dismissed Hide dismissed
},
params: {},
body: {
Expand Down
Loading
Loading