function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ColinKenworthy2ColinKenworthy2 

Looking for Function or Var that represents the Std Domain (eg "na2.salesforce.com")

Is there some function or global var that I can use to get from my VF page to a standard page? I want the standard email edit page for my email template.

 

In sandbox in my VF page I have a button that executes this javascript

 

location.replace("/email/author/emailauthor.jsp?retURL=/{!Onboarding_Request__c.Id}&p3_lkid={!Onboarding_Request__c.Id}&template_id=00X200000013Z9D&p26=0D220000000CaoV:abc@xyz.com:XYZ GLOBAL mailbox&p24=...etc.

 but it takes me to https://c.cs2.visual.force.com/email/author/emailauthor.jsp....etc.

... whereas where I really want to go is to https://cs2.salesforce.com/email/author/emailauthor.jsp....etc.  (the sandbox domain for my regular standard pages).

 

Now the emailauthor page from the visual.force.com domain does work however it is implemented slightly differently in htat the email preview is in a fixed size area with no scrollbars. From the standard domain it is much nicer in that the preview resizes to the email and it can all be seen.

 

So what I'd like to do is something like:

 

location.replace("{!$STDDOMAIN}/email/author/emailauthor.jsp?retURL=/{!Onboarding_Request__c.Id}&p3_lkid=...etc.

 if such a function or variable should exist.

 

Is anyone aware of a way to do this?

 

TIA.

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
aballardaballard

Can't you use Urlfor to generate the full URL for the action you want?  Where did you get this url from?  If it correspond to some standard action you should be able to url urlfor with that action name to ge what you want (and in a way that won't break if salesforce changes the url in future...)

 

All Answers

WesNolte__cWesNolte__c

I think this should do the trick:

 

$Api

Description:A global merge field type to use when referencing API URLs.
Use:
  1. Select the field type: $Api.
  2. Select a merge field, such as:
    • $Api.Enterprise_Server_URL__xxx: The Enterprise WSDL SOAP endpoint where xxx represents the version of the API. For example, $Api.Enterprise_Server_URL_140 is the merge field value for version 14.0 of the API.
    • $Api.Partner_Server_URL__xxx: The Partner WSDL SOAP endpoint where xxx represents the version of the API.$Api.Partner_Server_URL_120 is the merge field value for version 12.0 of the API.
    • $Api.Session_ID: The session ID.
ColinKenworthy2ColinKenworthy2

Sorry, what I'm after is a merge field that when used in a VF page (ie from a visual.force.com domain) will give me the regular salesforce.com domain name for my org e.g. "cs2.salesforce.com" .

 

I tried the above but it gave me https://c.cs2.visual.force.com/...etc. which is the VF domain.

WesNolte__cWesNolte__c

Sorry which API method did you use (there's no code in your post)?

 

I've used: $Api.Partner_Server_URL_90

And I've gotten: https://cs2.salesforce.com/services/Soap/u/9.0/xxxxx0000zdh

 

Wes

ColinKenworthy2ColinKenworthy2

Hi Wes,

I've  just used  {!$Api.Partner_Server_URL_90} in a VF page in my sandbox and it shows

 

https://c.cs2.visual.force.com/services/Soap/u/9.0/xxxxxx000008MXH

 

I'm not sure why we are seeing differrent results. I'm in a UE org if that makes a difference.

regards

Colin.

aballardaballard

Can't you use Urlfor to generate the full URL for the action you want?  Where did you get this url from?  If it correspond to some standard action you should be able to url urlfor with that action name to ge what you want (and in a way that won't break if salesforce changes the url in future...)

 

This was selected as the best answer
WesNolte__cWesNolte__c

High-five for UE.

 

I've no idea, we seem to be using it the same way. You've got premier support with UE, bump them for an answer? They're pretty good.

 

Wes

ColinKenworthy2ColinKenworthy2

The following seems to return the part of the URL I was after (from a VF page in my sandbox, it should work when deployed too)

 

 {!LEFT(  URLFOR($Action.Account.New), FIND('001',URLFOR($Action.Account.New))-2  )}

 

returns

 

https://cs2.salesforce.com

 

(and not https://c.cs2.visual.force.com as I was getting before).

osamanosaman

If you tried your previous solution, it would work in both the environments. When you don't specify the host, Salesforce picks up the current host. So, no matter you are in sandbox or production environment.