diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json index 5b11fa8b6f..dfb4c49080 100644 --- a/apps/web/public/static/locales/en/common.json +++ b/apps/web/public/static/locales/en/common.json @@ -3044,5 +3044,6 @@ "could_not_find_slug_to_publish_org": "Could not find slug to publish the organization", "picklist": "Picklist", "name_or_email": "Name or Email", + "salesforce_round_robin_skip_fallback_to_lead_owner": "If no contact is found, fallback to lead owner if it exists", "ADD_NEW_STRINGS_ABOVE_THIS_LINE_TO_PREVENT_MERGE_CONFLICTS": "↑↑↑↑↑↑↑↑↑↑↑↑↑ Add your new strings above here ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑" } diff --git a/packages/app-store/salesforce/components/EventTypeAppCardInterface.tsx b/packages/app-store/salesforce/components/EventTypeAppCardInterface.tsx index 9f6dbcba8e..66f87819f2 100644 --- a/packages/app-store/salesforce/components/EventTypeAppCardInterface.tsx +++ b/packages/app-store/salesforce/components/EventTypeAppCardInterface.tsx @@ -46,6 +46,7 @@ const EventTypeAppCard: EventTypeAppCardComponent = function EventTypeAppCard({ const onBookingWriteToRecord = getAppData("onBookingWriteToRecord") ?? false; const onBookingWriteToRecordFields = getAppData("onBookingWriteToRecordFields") ?? {}; const ignoreGuests = getAppData("ignoreGuests") ?? false; + const roundRobinSkipFallbackToLeadOwner = getAppData("roundRobinSkipFallbackToLeadOwner") ?? false; const { t } = useLocale(); @@ -522,6 +523,18 @@ const EventTypeAppCard: EventTypeAppCardComponent = function EventTypeAppCard({ }} /> + {checkOwnerSelectedOption.value === SalesforceRecordEnum.CONTACT ? ( +
+ { + setAppData("roundRobinSkipFallbackToLeadOwner", checked); + }} + /> +
+ ) : null}
0) { + // See if a contact was found first + const contactQuery = searchResult.searchRecords.filter( + (record) => record.attributes?.type === SalesforceRecordEnum.CONTACT + ); + + if (contactQuery.length > 0) { + records = contactQuery as ContactRecord[]; + } else { + // If not fallback to lead + const leadQuery = searchResult.searchRecords.filter( + (record) => record.attributes?.type === SalesforceRecordEnum.LEAD + ); + if (leadQuery.length > 0) { + records = leadQuery as ContactRecord[]; + } + } + } + } + // If falling back to contacts, check for the contact before returning the leads or empty array if ( appOptions.createEventOn === SalesforceRecordEnum.LEAD && diff --git a/packages/app-store/salesforce/zod.ts b/packages/app-store/salesforce/zod.ts index db8b96a915..2354728e35 100644 --- a/packages/app-store/salesforce/zod.ts +++ b/packages/app-store/salesforce/zod.ts @@ -41,6 +41,7 @@ export const appDataSchema = eventTypeAppCardZod.extend({ .default(SalesforceRecordEnum.CONTACT) .optional(), ifFreeEmailDomainSkipOwnerCheck: z.boolean().optional(), + roundRobinSkipFallbackToLeadOwner: z.boolean().optional(), skipContactCreation: z.boolean().optional(), createEventOn: z.nativeEnum(SalesforceRecordEnum).default(SalesforceRecordEnum.CONTACT).optional(), createNewContactUnderAccount: z.boolean().optional(),