Skip to content

Commit

Permalink
chore: Salesforce - Add logging (#19047)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeauyeung authored Feb 3, 2025
1 parent 1043085 commit 4475509
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/app-store/salesforce/lib/CrmService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,8 @@ export default class SalesforceCRMService implements CRM {
return;
}

this.log.info(`Writing to recordId ${contactId} on fields ${fieldsToWriteOn}`);

const writeOnRecordBody = await this.buildRecordUpdatePayload({
existingFields,
personRecord,
Expand All @@ -928,6 +930,9 @@ export default class SalesforceCRMService implements CRM {
organizerEmail,
calEventResponses,
});

this.log.info(`Final writeOnRecordBody contains fields ${Object.keys(writeOnRecordBody)}`);

// Update the person record
await conn
.sobject(personRecordType)
Expand Down Expand Up @@ -964,6 +969,11 @@ export default class SalesforceCRMService implements CRM {

// Skip if field should only be written when empty and already has a value
if (fieldConfig.whenToWrite === WhenToWriteToRecord.FIELD_EMPTY && personRecord[field.name]) {
this.log.info(
`Writing to field ${field.name} on contactId ${personRecord?.id} with value ${
personRecord[field.name]
}`
);
continue;
}

Expand Down Expand Up @@ -1156,7 +1166,7 @@ export default class SalesforceCRMService implements CRM {
const existingFieldNames = existingFields.map((field) => field.name);

const query = await conn.query(
`SELECT ${existingFieldNames.join(", ")} FROM ${personRecordType} WHERE Id = '${contactId}'`
`SELECT Id, ${existingFieldNames.join(", ")} FROM ${personRecordType} WHERE Id = '${contactId}'`
);

if (!query.records.length) {
Expand Down

0 comments on commit 4475509

Please sign in to comment.