You need to sign in to do that
Don't have an account?
rohitmarathe
Getting Salesforce instance type in apex class
Hi,
I am sending emails through my Apex class(NOT VisualForce APEX class). The text body of EMail contains the hyperlink to one of my Visualforce page. But depending on the Salesforce account type the instance name in the URL changes.(Example: https://cs2.salesforce.com/apex/myTimeSheets).
In above case cs2 can be na1 or na2 depending on instance type.
Is there any method in APEX by which I can get the name of the SF instance?
This is very simple in SControl but I am not getting anything in Apex fopr the same.
I am sending emails through my Apex class(NOT VisualForce APEX class). The text body of EMail contains the hyperlink to one of my Visualforce page. But depending on the Salesforce account type the instance name in the URL changes.(Example: https://cs2.salesforce.com/apex/myTimeSheets).
In above case cs2 can be na1 or na2 depending on instance type.
Is there any method in APEX by which I can get the name of the SF instance?
This is very simple in SControl but I am not getting anything in Apex fopr the same.
This works is supported in the UI on buttons and links.
I don't see why it wouldn't work from an email, but the user has to be logged into the correct instance of salesforce.
A relative url won't work in mail. (Your browser knows which webserver the html page with the relative link in it came from - your mailclient however has no idea to which webserver/domain you're referring to if you just give it a /folder/page )
The Apex Email classes can make use of mail templates ... (and some objects have fields like {!Case.Link} etc ... which you can include in mail templates but I gues that doesn't help you much further ...)
David
Message Edited by David VP on 10-08-2008 09:55 PM
Does anybody've solved that issue?
I solved this issue by placing the page domain into a hidden field and isolating the Salesforce instance from the domain string in the controller.
For example in the visualforce page:
And then in the controller, maybe something like this for example:
In this case, where the domain is for a managed package with a namespace - i.e. namespace.na7.visual.force.com
Even easier from sites;