You need to sign in to do that
Don't have an account?

Need to derive URL for /secur/frontdoor
I want to derive a general purpose JavaScript script that uses for example the URL for /secur/frontdoor.jsp, but I don't want to assume that it will aways start with https://na1.salesforce.com.
Can I safely assume that all of the URLs available via scontrol merge fields (Scontrol_URL, API_Enterprise_Server_URL_25, API_Enterprise_Server_URL_30, Scontrol_JavaCodebase, and Scontrol_JavaArchive) will always start with the same base for any customer session? If not, which one will be the right one to use for this purpose?
My preference is to use Scontrol_URL, extract it's base URL, and then assume that this is good enough to build up URLs for /secur/frontdoor, /servlet/servlet.SoapApi, and also to redirect the user to an object page (such as by appending Opportunity_ID to the base URL).
Nick
Hi Nick,
Any url you decide to use is fine. The context is the user. Assuming the user is logged in, all the urls will point to the correct host for the user. You could even derive the host from the location property of the hosting page (document.parent.parent.document.location or some such).
string apiUrl = sforceService.Url;
return apiUrl.Substring(0, apiUrl.IndexOf("/services")).Replace("-api","");
Harold,
Thanks for the suggestion, but I've lost you. In your example
string apiUrl = sforceService.Url;
where does the sforceService object come from?
Thanks,
Nick
Hi Nick,
the sforceService object is the "binding" object in the samples. It is the main object that all the methods hang off of. In the case of .Net it is a class and has a url property. In java this would be the SoapBindingStub object.
For a customer in Japan, this algorithm incorrectly returns
https://ap0.salesforce.com/0051.....
where it should return
https://ap.salesforce.com/0051.....
Is there an algorithm that will work worldwide?
Michael S. Scherotter
Here's a snippet I use to derive the host Url from the API Url:
string apiUrl = sforceService.Url;
return apiUrl.Substring(0, apiUrl.IndexOf("/services")).Replace("-api","");
Hi Michael S.,
The recommended method to determine the url is to use the describe call which contains 3 urls "templates" for displaying various views on an object. The views supported are detail, edit and new. This means that we provide a url for viewing the object, going directly to an edit screen or directly to a "new" object screen.
This property is not available on every object, but only for the "main" objects such as Account, Contact, etc. The format, and this is the part that relates to the post, is:
https://[server_instance]/{mergeField}
Where [server_instance] is what you are trying to obtain with the algorithm from the post. The {mergeField} is the name of a field on the object being described, that you would replace with an actual value. So for my developer edition and account detail link from the describe would look like:
https://na1.salesforce.com/{ID}
And with the value:
https://na1.salesforce.com/001300000043mRjAAI
Now, you can run the describe on the account object and parse out the merge field to obtain the base url for any frontdoor.jsp link you want to construct.
Cheers
The detailURL field is not complete because the following objects do not have any value for detailURL even though I can make one up myself by appending the /ID onto the server URL:
Asset, Contract, Note, Partner, CaseHistory, CaseComment
Michael
So we should not make URLs to objects that do not have detailURL values?
Please explain the logic that we should follow to get the detailURL of any object.
Michael
I documented these, and some others, in case 358012...
Asset, Attachment, BusinessHours (mabye), Contract, MailmergeTemplate, Note, OpportunityLineItem, Pricebook2, Product2, SControl, User, UserRole, and WebLink all do not have URLs devines in the describeSObject return. If I recall I did test the https://[server].salesforce.com/ID url schema with each of these and get get at least the view page back for each... you'll have to test yourself to try the create/edit syntax.
I already coded around this problem so that case has been a relatively low priority for me to followup on.
Hope that helps.
What algorithm do you use to determine the [server]?
This does not work in Japan:
string apiUrl = sforceService.Url;
return apiUrl.Substring(0, apiUrl.IndexOf("/services")).Replace("-api","");
Michael
To determine the server, use the url from the describe of an Account.