Compare commits
2
Commits
v4.9.1-rc1
...
v4.9.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07778d22ed | ||
|
|
56df8bdf7c |
Vendored
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user