-
Notifications
You must be signed in to change notification settings - Fork 385
Add "RETL Scripts For Importing Salesforce Objects Into Unified Profiles" documentation #6166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c0b55ce
add retl scripts
forstisabella a868f91
[netlify-build]
forstisabella 474c6ef
Merge branch 'master' into create-sql-traits
forstisabella 2514de7
add note w/ default db nme [netlify-build]
forstisabella 96406ac
Apply suggestions from code review [netlify-build]
forstisabella fa2fffe
Merge branch 'master' into create-sql-traits
forstisabella 253dbe8
final editing pass [netlify-build]
forstisabella 3df8758
Apply suggestions from code review [netlify-build]
forstisabella 4288c51
Apply suggestions from code review [netlify-build]
forstisabella facde85
{netlify-build]
forstisabella 318780d
Merge branch 'create-sql-traits' of https://github.com/segmentio/segm…
forstisabella File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,102 @@ | ||||||
--- | ||||||
title: RETL Scripts For Importing Salesforce Objects Into Unified Profiles | ||||||
hidden: true | ||||||
--- | ||||||
Unified Profiles users can convert Salesforce objects with US phone number patterns (typically (555) 231-7654) into Segment Unify profiles with E.164 phone number formats (+15552317654) to support Unified Profiles lookup. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
Segment created three sample queries for Unified Profiles users to import common Salesforce objects: | ||||||
forstisabella marked this conversation as resolved.
Show resolved
Hide resolved
forstisabella marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
- [Accounts](#accounts) | ||||||
- [Contacts](#contacts) | ||||||
- [Leads](#leads) | ||||||
|
||||||
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`. | ||||||
|
||||||
> success "" | ||||||
> Segment creates a default database table (`segment_flex_unify`) during the [Segment for Flex](/docs/unified-profiles/segment-for-flex/){:target="_blank”} setup process. | ||||||
|
||||||
## Accounts | ||||||
|
||||||
To import Salesforce Accounts into Unified Profiles as Segment Unify profiles, create a RETL mapping with the following format. | ||||||
|
||||||
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. | ||||||
|
||||||
``` sql | ||||||
SELECT | ||||||
a.*, | ||||||
CASE | ||||||
WHEN a.PHONE REGEXP '^(\\([0-9]{3}\\) [0-9]{3}-[0-9]{4})$' AND a.BILLING_COUNTRY = 'US' | ||||||
THEN CONCAT('+1', REGEXP_REPLACE(a.PHONE, '[^0-9]','')) | ||||||
WHEN a.BILLING_COUNTRY != 'US' | ||||||
THEN REGEXP_REPLACE(a.PHONE, '[^0-9]','') | ||||||
ELSE a.PHONE | ||||||
END as phone, | ||||||
FROM | ||||||
<database_name.account_table> a | ||||||
WHERE | ||||||
a.PHONE IS NOT NULL | ||||||
AND a.BILLING_COUNTRY IS NOT NULL; | ||||||
``` | ||||||
|
||||||
Salesforce objects have several phone number-related fields. In this example query, the “PHONE” column is the primary contact phone number and what you import as the Profile’s 'phone' trait. The other phone fields for Salesforce Accounts are PersonHomePhone, PersonMobilePhone, & PersonOtherPhone, and could be substituted for "PHONE" in this query. | ||||||
forstisabella marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
After running this query, ‘phone’ can be used as an identifier used for lookups in Unified Profiles. | ||||||
|
||||||
|
||||||
## Contacts | ||||||
|
||||||
To import Salesforce Contacts into Unified Profiles as Segment Unify profiles, create a RETL mapping with the following format. | ||||||
|
||||||
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. | ||||||
|
||||||
``` sql | ||||||
SELECT | ||||||
c.*, | ||||||
CASE | ||||||
WHEN c.PHONE REGEXP '^(\\([0-9]{3}\\) [0-9]{3}-[0-9]{4})$' AND c.BILLING_COUNTRY = 'US' | ||||||
THEN CONCAT('+1', REGEXP_REPLACE(c.PHONE, '[^0-9]','')) | ||||||
WHEN c.BILLING_COUNTRY != 'US' | ||||||
THEN REGEXP_REPLACE(c.PHONE, '[^0-9]','') | ||||||
ELSE c.PHONE | ||||||
END as phone, | ||||||
FROM | ||||||
<database_name.contact_table> c | ||||||
WHERE | ||||||
c.PHONE IS NOT NULL | ||||||
AND c.BILLING_COUNTRY IS NOT NULL; | ||||||
``` | ||||||
|
||||||
Salesforce objects have several phone number-related fields. In this example query, the “PHONE” column is the primary contact phone number and what you import as the Profile’s 'phone' trait. The other phone fields for Salesforce Contacts are HomePhone, MobilePhone, & OtherPhone, and could be substituted for "PHONE" in this query. | ||||||
forstisabella marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
After running this query, ‘phone’ can be used as an identifier used for lookups in Unified Profiles. | ||||||
|
||||||
## Leads | ||||||
|
||||||
To import Salesforce Leads into Unified Profiles as Segment Unify profiles, create a RETL mapping with the following format. | ||||||
|
||||||
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. | ||||||
|
||||||
``` sql | ||||||
SELECT | ||||||
l.*, | ||||||
CASE | ||||||
WHEN l.PHONE REGEXP '^(\\([0-9]{3}\\) [0-9]{3}-[0-9]{4})$' AND l.BILLING_COUNTRY = 'US' | ||||||
THEN CONCAT('+1', REGEXP_REPLACE(l.PHONE, '[^0-9]','')) | ||||||
WHEN l.BILLING_COUNTRY != 'US' | ||||||
THEN REGEXP_REPLACE(l.PHONE, '[^0-9]','') | ||||||
ELSE l.PHONE | ||||||
END as phone, | ||||||
FROM | ||||||
<database_name.lead_table> l | ||||||
WHERE | ||||||
l.PHONE IS NOT NULL | ||||||
AND l.BILLING_COUNTRY IS NOT NULL; | ||||||
``` | ||||||
|
||||||
Salesforce objects have several phone number-related fields. In this example query, the “PHONE” column is the primary contact phone number and what you import as the Profile’s 'phone' trait. The other phone fields for Salesforce Leads are HomePhone, MobilePhone, & OtherPhone, and could be substituted for "PHONE" in this query. | ||||||
|
||||||
After running this query, ‘phone’ can be used as an identifier used for lookups in Unified Profiles. | ||||||
|
||||||
## Troubleshooting | ||||||
If these queries don't return phone numbers in E.164 format, examine your existing data and change the REGEX patterns as appropriate. | ||||||
|
||||||
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 REGEX 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 REGEX patterns in the provided queries. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.