Compare commits

...
2 Commits
Author SHA1 Message Date
GitHub Actions 07778d22ed chore: release v4.9.1
Post release / release (push) Canceled after 0s
2025-01-16 18:01:24 +00:00
Joe Au-Yeung 56df8bdf7c feat: Salesforce - map booking questions to event record (#18532) 2025-01-16 12:28:07 -05:00
3 changed files with 33 additions and 18 deletions
View File
+2 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@calcom/web",
"version": "4.9.1-rc1",
"version": "4.9.1",
"private": true,
"scripts": {
"analyze": "ANALYZE=true next build",
@@ -198,6 +198,5 @@
"budgetPercentIncreaseRed": 20,
"minimumChangeThreshold": 500,
"showDetails": true
},
"stableVersion": "4.9.0"
}
}
+31 -15
View File
@@ -182,20 +182,7 @@ export default class SalesforceCRMService implements CRM {
private salesforceCreateEvent = async (event: CalendarEvent, contacts: Contact[]) => {
const appOptions = this.getAppOptions();
const customFieldInputsEnabled =
appOptions?.onBookingWriteToEventObject && appOptions?.onBookingWriteToEventObjectMap;
const customFieldInputs = customFieldInputsEnabled
? await this.ensureFieldsExistOnObject(Object.keys(appOptions?.onBookingWriteToEventObjectMap), "Event")
: [];
const confirmedCustomFieldInputs: {
[key: string]: any;
} = {};
for (const field of customFieldInputs) {
confirmedCustomFieldInputs[field.name] = appOptions.onBookingWriteToEventObjectMap[field.name];
}
const writeToEventRecord = await this.generateWriteToEventBody(event);
let ownerId = null;
if (event?.organizer?.email) {
@@ -216,7 +203,7 @@ export default class SalesforceCRMService implements CRM {
const createdEvent = await this.salesforceCreateEventApiCall(event, {
EventWhoIds: contacts.map((contact) => contact.id),
...confirmedCustomFieldInputs,
...writeToEventRecord,
...(ownerId && { OwnerId: ownerId }),
}).catch(async (reason) => {
if (reason === sfApiErrors.INVALID_EVENTWHOIDS) {
@@ -1006,6 +993,35 @@ export default class SalesforceCRMService implements CRM {
return writeOnRecordBody;
}
private async generateWriteToEventBody(event: CalendarEvent) {
const appOptions = this.getAppOptions();
const customFieldInputsEnabled =
appOptions?.onBookingWriteToEventObject && appOptions?.onBookingWriteToEventObjectMap;
if (!customFieldInputsEnabled) return {};
const customFieldInputs = customFieldInputsEnabled
? await this.ensureFieldsExistOnObject(Object.keys(appOptions?.onBookingWriteToEventObjectMap), "Event")
: [];
const confirmedCustomFieldInputs: {
[key: string]: any;
} = {};
for (const field of customFieldInputs) {
confirmedCustomFieldInputs[field.name] = await this.getTextFieldValue({
fieldValue: appOptions.onBookingWriteToEventObjectMap[field.name],
fieldLength: field.length,
calEventResponses: event.responses,
bookingUid: event?.uid,
});
}
return confirmedCustomFieldInputs;
}
private async getTextFieldValue({
fieldValue,
fieldLength,