Skip to content

Commit 1853a82

Browse files
committed
bring back sfmc + warehouse [netlify-build]
1 parent f4b2eb5 commit 1853a82

File tree

2 files changed

+118
-10
lines changed

2 files changed

+118
-10
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
title: RETL Queries for Importing Salesforce Objects Into Unified Profiles in Flex
3+
hidden: true
4+
---
5+
You can use the following SQL queries to convert Salesforce objects with US phone number patterns (typically (555) 231-7654) into Segment Unify profiles with E.164 phone number formats (+15552317654). Unified Profiles in Flex requires phone numbers used for profile lookups to be in E.164 format.
6+
7+
Segment created three sample queries for Unified Profiles users to import common Salesforce objects:
8+
- [Accounts](#accounts)
9+
- [Contacts](#contacts)
10+
- [Leads](#leads)
11+
12+
To selectively import columns, replace the `a*`, `c*`, or `l*` with a list of fields to selectively import. For example, if you wanted to only import the ID, NAME, and ADDRESS fields for your Accounts, you'd replace `a*` with `a.ID, a.NAME, a.ADDRESS`.
13+
14+
> success ""
15+
> Segment creates a default database table (`segment_flex_unify`) during the [Segment for Flex](/docs/unified-profiles/segment-for-flex/){:target="_blank”} setup process.
16+
17+
## Accounts
18+
19+
To import Salesforce Accounts into Unified Profiles as Segment Unify profiles, create a RETL mapping with the following format.
20+
21+
Replace `<database_name.account_table>` with your database name and account table, `PHONE` with the name of the column in your warehouse that contains phone numbers, and `BILLING_COUNTRY` with the name of the column in your warehouse that contains the account's country. In this sample query, the `PHONE` column is the primary contact phone number and what you import as the Profile’s 'phone' trait.
22+
23+
The other phone fields for Salesforce Accounts are PersonHomePhone, PersonMobilePhone, & PersonOtherPhone, and could be substituted for `PHONE` in this query. **You can only import one phone number field as the identifier used for lookups in Unified Profiles.**
24+
25+
``` sql
26+
SELECT
27+
a.*,
28+
CASE
29+
WHEN a.PHONE REGEXP '^(\\([0-9]{3}\\) [0-9]{3}-[0-9]{4})$' AND a.BILLING_COUNTRY = 'US'
30+
THEN CONCAT('+1', REGEXP_REPLACE(a.PHONE, '[^0-9]',''))
31+
WHEN a.BILLING_COUNTRY != 'US'
32+
THEN REGEXP_REPLACE(a.PHONE, '[^0-9]','')
33+
ELSE a.PHONE
34+
END as phone,
35+
FROM
36+
<database_name.account_table> a
37+
WHERE
38+
a.PHONE IS NOT NULL
39+
AND a.BILLING_COUNTRY IS NOT NULL;
40+
```
41+
42+
After running this query, you can use ‘phone’ for lookups in Unified Profiles.
43+
44+
45+
## Contacts
46+
47+
To import Salesforce Contacts into Unified Profiles as Segment Unify profiles, create a RETL mapping with the following format.
48+
49+
Replace `<database_name.contact_table>` with your database name and account table, `PHONE` with the name of the column in your warehouse that contains phone numbers, and `BILLING_COUNTRY` with the name of the column in your warehouse that contains the contact's country.
50+
51+
Salesforce objects have several phone number-related fields. In this sample query, the `PHONE` column is the primary contact phone number and what you import as the Profile’s 'phone' trait.
52+
53+
The other phone fields for Salesforce Contacts are HomePhone, MobilePhone, & OtherPhone, and could be substituted for `PHONE` in this query. **You can only import one phone number field as the identifier used for lookups in Unified Profiles.**
54+
55+
``` sql
56+
SELECT
57+
c.*,
58+
CASE
59+
WHEN c.PHONE REGEXP '^(\\([0-9]{3}\\) [0-9]{3}-[0-9]{4})$' AND c.MAILING_COUNTRY = 'US'
60+
THEN CONCAT('+1', REGEXP_REPLACE(c.PHONE, '[^0-9]',''))
61+
WHEN c.MAILING_COUNTRY != 'US'
62+
THEN REGEXP_REPLACE(c.PHONE, '[^0-9]','')
63+
ELSE c.PHONE
64+
END as phone,
65+
FROM
66+
<database_name.contact_table> c
67+
WHERE
68+
c.PHONE IS NOT NULL
69+
AND c.MAILING_COUNTRY IS NOT NULL;
70+
```
71+
72+
After running this query, you can use ‘phone’ for lookups in Unified Profiles.
73+
74+
## Leads
75+
76+
To import Salesforce Leads into Unified Profiles as Segment Unify profiles, create a RETL mapping with the following format.
77+
78+
Replace `<database_name.lead_table>` with your database name and lead table, `PHONE` with the name of the column in your warehouse that contains phone numbers, and `BILLING_COUNTRY` with the name of the column in your warehouse that contains the lead's country.
79+
80+
Salesforce objects have several phone number-related fields. In this sample query, the `PHONE` column is the primary contact phone number and what you import as the Profile’s 'phone' trait.
81+
82+
The other phone fields for Salesforce Leads are HomePhone, MobilePhone, & OtherPhone, and could be substituted for `PHONE` in this query. **You can only import one phone number field as the identifier used for lookups in Unified Profiles.**
83+
84+
``` sql
85+
SELECT
86+
l.*,
87+
CASE
88+
WHEN l.PHONE REGEXP '^(\\([0-9]{3}\\) [0-9]{3}-[0-9]{4})$' AND l.COUNTRY = 'US'
89+
THEN CONCAT('+1', REGEXP_REPLACE(l.PHONE, '[^0-9]',''))
90+
WHEN l.COUNTRY != 'US'
91+
THEN REGEXP_REPLACE(l.PHONE, '[^0-9]','')
92+
ELSE l.PHONE
93+
END as phone,
94+
FROM
95+
<database_name.lead_table> l
96+
WHERE
97+
l.PHONE IS NOT NULL
98+
AND l.COUNTRY IS NOT NULL;
99+
```
100+
101+
After running this query, you can use ‘phone’ for lookups in Unified Profiles.
102+
103+
## Troubleshooting
104+
If these queries don't return phone numbers in E.164 format, examine your existing data and change the REGEX patterns as appropriate.
105+
106+
Because the format in which an international phone number is saved in Salesforce largely depends on how users input them into the system, Salesforce administrators can add form validation methods, like input field validation rules with REGEXP functions, to guide users to input phone numbers in specific formats. These form validation methods may impact the format of the phone numbers in your database, and might require you to change the REGEXP patterns in the provided queries.

src/unified-profiles/unified-profiles-workspace.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ After you've selected the source of your customer data, set up the connections b
2727

2828
You can set up 1 of the following options:
2929
- [CSV](#csv)
30-
- [Salesforce](#salesforce)
30+
- [Salesforce and a data warehouse](#salesforce-and-a-data-warehouse)
3131
- [A data warehouse](#data-warehouse)
3232
- [A website or mobile app source](#website-or-mobile-app)
3333

@@ -47,17 +47,19 @@ If your data source isn't listed on this page, click **My source isn't listed**.
4747
_(Optional)_: To upload additional CSV files, repeat steps 1-6.
4848
7. When you've finished uploading your profiles, click **Add identifiers and traits** to start [Step 3: Add identifiers and traits](#step-3-add-identifiers-and-traits).
4949

50-
### Salesforce
50+
### Salesforce and a data warehouse
5151

52-
1. On the Getting started page, select **Connect Salesforce** and click **Next**.
52+
> info "Sample queries for importing records into Unified Profiles"
53+
> Not sure where to start with the SQL queries that define your model? See the [RETL Queries for Importing Salesforce Objects into Unified Profiles in Flex](/docs/unified-profiles/create-sql-traits){:target="_blank"} documentation.
54+
55+
1. On the Getting started with Segment page, click **Connect Salesforce**.
5356
2. You are redirected to the Salesforce login screen. Sign in to Salesforce with a user that has _View all Records_ permissions.
54-
3. Return to the Getting started page and click **Define model** to identify the data that Segment should import from Salesforce.
55-
4. Select a collection from the dropdown menu and add one or more columns to your model.
56-
5. When you're satisfied with your data model, click **Create model**.
57-
6. Segment redirects you to the Getting started page. Click **Create mapping** to create a framework for the data Segment should map from Salesforce to your downstream tools.
58-
7. On the Create mapping page, select which Salesforce fields Segment should send to your downstream tools.
59-
8. When you're satisfied with your mapping, click **Create mapping**.
60-
9. After Segment marks the "Add connections" tile as complete, add additional connections or click **Add identifiers and traits** to start [Step 3: Add identifiers and traits](#step-3-add-identifiers-and-traits).
57+
3. On the Getting started with Segment page, click **Connect data warehouse**.
58+
4. Select your data warehouse from the list of available warehouses, and click **Next**.
59+
5. Give your destination a name and enter the account credentials for a user that has read and write permissions. Click **Save**.
60+
6. After you've given your destination a name and entered your credentials, click **Next**.
61+
7. On the Getting started with Segment page, click **Define Model**.
62+
8. Create a SQL query that defines your model. After you've created a model, Segment uses your model to map data to your Reverse ETL destinations.
6163

6264
> warning "Records from your data warehouse and Salesforce might not be immediately available"
6365
> Segment's initial sync with your data warehouse can take up to 24 hours to complete. Segment syncs with Salesforce immediately after you connect it to your Unified Profiles workspace. This initial sync can take up to 72 hours. After Segment completes the initial sync with Salesforce, Segment initiates a sync with Salesforce every three hours.

0 commit comments

Comments
 (0)