You need to sign in to do that
Don't have an account?
highgosh
How to determine instance via APEX on a My Domain?
Using Apex in a trigger, how can one find the current SFDC instance (the pod - like "cs3") when in a sandbox logged in under a My Domain? Using Url.getSalesforceBaseUrl().getHost(); doesn't seem to get us there.
I ended up finding this routing table, which allows me to do a query for the OrgId via Apex, and then look at the 4th character in the OrgID which explains which SFDC instance (server) this is on.
All Answers
I am afraid you won't be able to et the instance using Apex if My domain is already deployed.
Hmmm, well, here's the challenge. Let's say I need to create a URL that will hit a Sites page. Let's say that the Site in question is running in a sandbox under a My Domain. Per documentation, if you want to create an secure URL (SSL), for some reason, the requirement is for the link to be changed to the following format.
https://mycompany.mysandbox.cs1.force.com
...thereby requiring that we know which SFDC server this Site is sitting on.
Documentation: http://na14.salesforce.com/help/doc/en/sites_creating_subdomain.htm
I'm not sure it's possible for us to figure this out programmatically, since the System.URL.getSalesforceBaseURL().getHost(); in this situation will respond back without the "cs##" included in it.
Help?
You are getting confused here.In
https://mycompany.mysandbox.cs1.force.com
mycompany is Site sub doamin which you have to register while creting a Force.com Site,it is not your My Domain which is the domain of your salesforce org not the Site.
I hope now it is clear to you.To get the URL of site try below code :-
Site.getCurrentSiteUrl();
You can also go through the below link for more :-
http://boards.developerforce.com/t5/Apex-Code-Development/Get-Current-Page-URL-in-Apex-Class-Full-amp-Exact-URL/td-p/134623
I ended up finding this routing table, which allows me to do a query for the OrgId via Apex, and then look at the 4th character in the OrgID which explains which SFDC instance (server) this is on.
This mapping does not always work.
We were moved to a new POD and the OrgId did not change (4th char still represents to orig org not the new org)
Also my findings show then the Url.getSalesforceBaseUrl().getHost(); returns the domain it was instatiated
Ex:
API (Force IDE execute Anon) will return the normal api domain with pod
when running APEX from native UI ( developer console) it returns the mydomain name
and when in a VF controller returns the VF domain.
Please reply if anyone finds a workaround.