Skip to content

Commit bd83b36

Browse files
authored
feat: Salesforce - add option to ignore guests (#17956)
* Enable option to ignore guests * Ignore guests in CRM Manager
1 parent 05e2029 commit bd83b36

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

apps/web/public/static/locales/en/common.json

+1
Original file line numberDiff line numberDiff line change
@@ -2826,6 +2826,7 @@
28262826
"single_select": "Single Select",
28272827
"multi_select": "Multi Select",
28282828
"group_meeting": "Group Meeting",
2829+
"salesforce_ignore_guests": "Do not create new records for guests added to the booking",
28292830
"ADD_NEW_STRINGS_ABOVE_THIS_LINE_TO_PREVENT_MERGE_CONFLICTS": "↑↑↑↑↑↑↑↑↑↑↑↑↑ Add your new strings above here ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑"
28302831
}
28312832

packages/app-store/salesforce/components/EventTypeAppCardInterface.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const EventTypeAppCard: EventTypeAppCardComponent = function EventTypeAppCard({
3939
const sendNoShowAttendeeDataField = getAppData("sendNoShowAttendeeDataField") ?? "";
4040
const onBookingWriteToRecord = getAppData("onBookingWriteToRecord") ?? false;
4141
const onBookingWriteToRecordFields = getAppData("onBookingWriteToRecordFields") ?? {};
42+
const ignoreGuests = getAppData("ignoreGuests") ?? false;
4243

4344
const { t } = useLocale();
4445

@@ -135,6 +136,16 @@ const EventTypeAppCard: EventTypeAppCardComponent = function EventTypeAppCard({
135136
}}
136137
/>
137138
</div>
139+
<div className="mb-4">
140+
<Switch
141+
label={t("salesforce_ignore_guests")}
142+
labelOnLeading
143+
checked={ignoreGuests}
144+
onCheckedChange={(checked) => {
145+
setAppData("ignoreGuests", checked);
146+
}}
147+
/>
148+
</div>
138149
{createEventOnSelectedOption.value === SalesforceRecordEnum.CONTACT ? (
139150
<div>
140151
<Switch

packages/app-store/salesforce/zod.ts

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const appDataSchema = eventTypeAppCardZod.extend({
3535
sendNoShowAttendeeDataField: z.string().optional(),
3636
onBookingWriteToRecord: z.boolean().optional(),
3737
onBookingWriteToRecordFields: z.record(z.string(), writeToRecordEntry).optional(),
38+
ignoreGuests: z.boolean().optional(),
3839
});
3940

4041
export const appKeysSchema = z.object({

packages/core/crmManager/crmManager.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,18 @@ export default class CrmManager {
2929

3030
public async createEvent(event: CalendarEvent, appOptions?: any) {
3131
const crmService = await this.getCrmService(this.credential);
32-
const { skipContactCreation } = crmService?.getAppOptions() || {};
32+
const { skipContactCreation = false, ignoreGuests = false } = crmService?.getAppOptions() || {};
33+
const eventAttendees = ignoreGuests ? [event.attendees[0]] : event.attendees;
3334
// First see if the attendees already exist in the crm
34-
let contacts = (await this.getContacts({ emails: event.attendees.map((a) => a.email) })) || [];
35+
let contacts = (await this.getContacts({ emails: eventAttendees.map((a) => a.email) })) || [];
3536
// Ensure that all attendees are in the crm
36-
if (contacts.length == event.attendees.length) {
37+
if (contacts.length == eventAttendees.length) {
3738
return await crmService?.createEvent(event, contacts);
3839
}
3940

4041
if (skipContactCreation) return;
4142
// Figure out which contacts to create
42-
const contactsToCreate = event.attendees.filter(
43+
const contactsToCreate = eventAttendees.filter(
4344
(attendee) => !contacts.some((contact) => contact.email === attendee.email)
4445
);
4546
const createdContacts = await this.createContacts(

0 commit comments

Comments
 (0)