9 Best Practices and Guidelines for Implementing My Domain In Salesforce



Before you plan to start to develop Lightning Components, you have to enable My Domain in the Salesforce Developer Edition org. This is required step for Lightning Components. If you want to use Lightning Components in your salesforce org, then you must enable My Domain in your org. 
My domain means custom domain. 

Then one question for sure come to your mind is why we need to add a Custom Domain to Your Org with My Domain?

Answer is: Custom domain is your own Salesforce server, kind of. Custom domain gives you your customized URL like https://yourDomain.my.salesforce.com/ , rather than a generic Salesforce instance URL which is like https://na70.salesforce.com/

Custom domain gives you:

  • Unique domain URL which represents your unique business.
  • Set your own custom login policy.
  • Redirect or Block requests that do not use the new domain name.
  • Improves your organization’s security.
  • Brand your own login screen and customize right frame content.
Note: If you already setup My domain in your org then skip below setup section.

How to enable or setup My Domain in the Developer Edition org?


Step 1: Choose Domain Name

  • Go to Setup -> enter My Domain in the Quick Find box -> then Select My Domain.
  • Enter the name for your chosen subdomain after https://  (Note: Be sure of your subdomain name before registering. Once your subdomain is registered, then only Salesforce Customer Support can change it). Your domain name can only include up to 40 characters, numbers, and hyphens characters. The name cannot start or end with a hyphen character.
  • Click Check Availability. A subdomain is your company name, but it must be unique. If selected subdomain name is already taken by some other users, then choose another one.
  • Click Register Domain. Salesforce takes a few minutes to update its naming registries from 30 seconds to 30 minutes.
  • You will receive an activation email when it's ready for testing.

Step 3 : Domain Ready for Testing


Once you received email, click on link to get back to the My Domain wizard where you test the links to your org`s subdomain URLs before rolling out the subdomain to your salesforce org. It will ask you to enter login credentials of current org.

Now check the browser URL which showing the new brand custom domain.

Click around your org and make sure all links are properly works which point to your new custom domain. This is very important step when you create custom domain in Production.
If you have customized the User Interface, check for hard links to your original URL.
 

Step 4 : Domain Deployed to Users



Now click on Deploy to Users button which Roll out the new domain to your org. Links are now redirected to your domain URL.

Now all users can see your new brand custom domain URL. After you deploy, you can control how requests are redirected to your domain. They can be redirected automatically, redirected with a warning, or not redirected at all.

Redirect policy: After My Domain is set, you will see Redirect policy option. Page requests that don't use the new domain name, such as old bookmarks using the instance name, have three options which are:

  • Redirected to the same page within the subdomain 
  • Redirected with a warning message to the same page within the subdomain 
  • Not redirected (Recommended)

Best Practices and Guidelines for Implementing My Domain:

  1. Before deploying subdomain that you have created with My Domain, communicate with your users about this change.
  2. It’s better to deploy this subdomain change during weekend. So you can trouble shoot issue if any.
  3. If you have hard coded references, then replace them with your subdomain URL.
  4. If your user’s bookmarks URLs then communicate with those users and provide new URL.
  5. Choose the first option in Redirect Policy which is Redirected with a warning to the same page within the domain to give users time to update their bookmarks with the new subdomain name. After all, set in few weeks or month then change the Redirect Policy to Not redirected. This option provides greatest level of security.
  6. Once you selected Not directed, existing URLs doesn’t work and user will get error when they try for existing URLs.
  7. When Redirect to the same page within the domain option selected then Bookmarks doesn’t work for partner portals.
  8. To login into custom domain from http://login.salesforce.com/, Use Custom Domain option.
  9. You can also share direct link to sub domain with your users.


If You Have the Following in Salesforce Org
Do the Following
Any API integrations into your Salesforce org
Check to see if the API client is directly referencing the server endpoint. Instead of using a hard-coded server URL, the API client should use the LoginResult.serverURL value returned by the login request. After your subdomain is deployed to users, Salesforce returns the server URL containing your subdomain. Redirect policy settings have no effect on any API calls. That is, Old calls to your salesforce instance URLs continue to work. However, the salesforce best practice is to use the value returned by Salesforce.
Email templates
You have to Replace references to the salesforce org’s instance URL with your new subdomain.
Custom Force.com apps or Custom Visualforce pages
You have to Replace references to the salesforce org’s instance URL with your new subdomain.
Salesforce Chatter
Before deploying it to users, communicate your users to update any bookmarks in the left navigation of their Salesforce Chatter groups.
Communities Zones (Ideas/ Chatter Answers / Answers)
You have to Manually update the email notification URLs. It`s easy to populate URL, to update an email notification URL, clear the existing email notification URL so that the field is blank and save the page. Then the system populates the field with your new My Domain or subdomain URL.


Authentication Configuration Options in My domain:

  • Go to Setup -> Search for My Domain -> go to Authentication Configuration section and click on Edit button.
  • Upload the Header logo which you want to show on your login pages which should be in JPG, PNG or GIF format. Logo size is 100 KB maximum and maximum dimension is 250 x 125 px.
  • Select Background Color of your Login page.
  • If you want to provide extra security to iOS user`s, then Use the native browser for user authentication on iOS. 
    On the login screen, you can select Authentication Service as an identity provider like social sign-on providers like Facebook or Google. Users can then login with their social account credentials. It`s like single sign on concept or SAML.
 
Let`s say, after all setup done you want to know what will be new URL of your org then check below:


URL For
Old URL- Without Subdomain
New URL- With Subdomain
Production Login
https://<YourSubdomain>.my.​salesforce.com
Production Application page or tab
https://<instance>.salesforce.com/<pageID>
https://<YourSubdomain>.my.​salesforce.com​/<pageID>
Production Visualforce page with no namespace
https://c.<instance>visual.force.com/apex/<pagename>
https://<YourSubdomain>--c.​<instance>.visual.​force.com​/apex​/<pagename>
Production Visualforce page with namespace
https://<yournamespace>.​<instance>.visual.​force.com​/apex/<pagename>
https://<YourSubdomain>--​<yournamespace>.​<instance>.visual.force.com​/apex/​
Sandbox Login
 https://<YourSubdomain>--<sandboxname>.<instance>.my.salesforce.com
Sandbox Application page or tab
https://<instance>.salesforce.com/<pageID>
https://<YourSubdomain>--<sandboxname>.<instance>.​salesforce.com​/<pageID>
Sandbox Visualforce page with no namespace
https://c.<instance>visual.force.com/apex/<pagename>
 https://<YourSubdomain>--<sandboxname>--c.<instance>.visual.force.com/apex/<pagename>
  

Don’t forget to like or comment.

As always, please feel free to get in touch me as I would be more than happy to assist you with any of your Salesforce development needs.

  Other blogs:

Understand Lightning Design System Key Principles in 25 Minutes

9 Configurations In Lightning Experience Tips You Need To Learn Now. 

Understand Lightning Design System Key Principles in 25 Minutes

Lightning Experience Rollout Strategy that you can`t learn from book 

Learn Salesforce Lightning Experience Basics In 15 Minutes