From 817d8738a942fb9b48a1b97716b23f4ffa8ac8bd Mon Sep 17 00:00:00 2001
From: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
Date: Wed, 23 Oct 2024 23:07:13 -0400
Subject: [PATCH] feat: Salesforce - on booking, write to custom fields
[CAL-4570] (#17257)
* Save and enable custom fields
* Write to custom fields on booking
* Add validations
---
apps/web/public/static/locales/en/common.json | 3 +
.../components/EventTypeAppCardInterface.tsx | 101 +++++++++++++++++-
.../app-store/salesforce/lib/CrmService.ts | 43 ++++++++
packages/app-store/salesforce/zod.ts | 2 +
4 files changed, 148 insertions(+), 1 deletion(-)
diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json
index 7be8c20963..db8b629f57 100644
--- a/apps/web/public/static/locales/en/common.json
+++ b/apps/web/public/static/locales/en/common.json
@@ -2689,6 +2689,9 @@
"reschedule_with_different_timeslot": "Reschedule with different timeslot",
"we_dont_have_id_for_the_new_event": "We don't have ID for the new event. Please go to the Routing Form and save it again.",
"rerouted_booking_successfully_redirecting_to_booking_page": "Rerouted booking successfully. Redirecting to booking page",
+ "on_booking_write_to_event_object": "On booking, write to event object",
+ "field_name": "Field name",
+ "add_new_field": "Add new field",
"you_dont_have_access_to_reroute_this_booking": "You don't have access to reroute this booking",
"form_response_not_found": "Form response not found",
"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 ed232e6626..a039260068 100644
--- a/packages/app-store/salesforce/components/EventTypeAppCardInterface.tsx
+++ b/packages/app-store/salesforce/components/EventTypeAppCardInterface.tsx
@@ -8,7 +8,7 @@ import type { EventTypeAppCardComponent } from "@calcom/app-store/types";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { SchedulingType } from "@calcom/prisma/enums";
-import { Switch, Alert, Select } from "@calcom/ui";
+import { Switch, Alert, Select, Button, InputField, showToast } from "@calcom/ui";
import { SalesforceRecordEnum } from "../lib/recordEnum";
import type { appDataSchema } from "../zod";
@@ -25,6 +25,8 @@ const EventTypeAppCard: EventTypeAppCardComponent = function EventTypeAppCard({
const createLeadIfAccountNull = getAppData("createLeadIfAccountNull");
const createNewContactUnderAccount = getAppData("createNewContactUnderAccount");
const createEventOn = getAppData("createEventOn") ?? SalesforceRecordEnum.CONTACT;
+ const onBookingWriteToEventObject = getAppData("onBookingWriteToEventObject") ?? false;
+ const onBookingWriteToEventObjectMap = getAppData("onBookingWriteToEventObjectMap") ?? {};
const { t } = useLocale();
const recordOptions = [
@@ -45,6 +47,11 @@ const EventTypeAppCard: EventTypeAppCardComponent = function EventTypeAppCard({
checkOwnerOptions.find((option) => option.value === roundRobinSkipCheckRecordOn) ?? checkOwnerOptions[0]
);
+ const [newOnBookingWriteToEventObjectField, setNewOnBookingWriteToEventObjectField] = useState({
+ field: "",
+ value: "",
+ });
+
return (