Slaesforce FAQ

how to get salesforce instance url in visualforce page

by Prof. Griffin Miller III Published 2 years ago Updated 2 years ago
image

Instead of constructing the visual.force.com url, simply construct the salesforce.com url, which is very simple given the URL.getSalesforceBaseUrl ().getHost () method. Example code: String sfUrl=URL.getSalesforceBaseUrl ().getHost (); String myURL = 'https://'+sfUrl+'/apex/NAMESPACE__pagename?Id=';

Full Answer

How to get the URL of a page in Salesforce?

If your page is using a controller or extension (if it's not, just create an extension) then you should be able to get the URL you're after using the referer header for the Visualforce page. Show activity on this post. You can then bind apex:outputText to this controller variable. Thanks for contributing an answer to Salesforce Stack Exchange!

How to get the canonical URL of an Org in Salesforce?

You are looking for URL.getSalesforceBaseUrl (). The Winter 19 release is introducing another method to get the URL, which will give you the canonical URL for your org: URL.getOrgDomainUrl (). Returns the canonical URL for your org.

Why doesn't getsalesforcebaseurl provide this information in the URL?

This is a known issue, the URL.getSalesforceBaseUrl()should provide this information but it does not. However in reality this has very limited functional impact. Their instance and apex domains are interchangeable in the sense that requesting a URL that does not belong to one gets redirected to the other.

How to get the string version of a form in Salesforce?

If you would like the string version, simply call .toExternalForm () on that instance. For example: Show activity on this post. These methods will work reliably across Production, Sandboxes, Dev Orgs, etc.

See more

image

How do I find my Salesforce instance URL?

In WindowsHold the Windows key and press R.At the run dialog, type in cmd and press enter.After a command prompt appears, type in nslookup example.my.salesforce.com (replace example with your My Domain).A few lines down you will see a line that starts with "Name:" The naXX afterwards will be your instance name.

How do I get the current URL in Visualforce page?

In that community branding, we have added a developed Visualforce page which fetches the current URL by using ApexPages. Currentpage(). getParameters(). get('referer') and we have few links in the visualforce page to redirect a page which already been created as a community page.

How do I create a Visualforce page using URL in Salesforce?

Visualforce page in Salesforce can be created using developer console, using Visualforce pages and using URL....To create vf pages in Salesforce navigate to Setup | Build | Develop | Visualforce pages.Click on New button to create vf page.Enter label and Name.Finally click on save button.

How do I find the URL of an Apex class?

How To Get Current Page URL In ApexString urlVal = Apexpages. currentPage(). getUrl();public void getPageURL() {String hostVal = ApexPages.currentPage().getHeaders().get('Host');String urlVal = Apexpages.currentPage().getUrl();String URLL = 'https://' + hostVal+ urlVal;}

How do I use URL in Visualforce page?

A custom link or button is required on standard/VF page which should open the destination link in a different App. Requirement is to ensure that the page opens in a specific app. Solution would be use of tsid parameter in the url with value as APP id.

What is ApexPages StandardController?

StandardController objects reference the pre-built Visualforce controllers provided by Salesforce. The only time it is necessary to refer to a StandardController object is when defining an extension for a standard controller. StandardController is the data type of the single argument in the extension class constructor.

How do I call a Visualforce page from Apex class?

To call an Apex class from custom button or link on the object detail page, create a VisualForce page and call the Apex class method via the action attribute to make it work. Following is some sample code showing how to do that. The action method invoked when this page is requested by the server.

How do I access Visualforce pages in Salesforce?

From Setup, enter Visualforce Pages in the Quick Find box, then select Visualforce Pages and click the name of a Visualforce page to view its details, including when it was created, when it was last modified, and the Visualforce markup associated with the page.

How do I add a Visualforce page to a page layout in Salesforce?

Go to Build=>Customize=>Accounts=>Page Layouts. Click on Page Layouts as shown above....Follow the steps to embed visualforce page.Drag a new section into page layout.Now Select Visualforce page.Drag Visualforce from the list to new section.Click on Save Button.

How do I get a domain URL in Salesforce Apex?

Url. getOrgDomainUrl() to get domain URL using apex in Salesforce. Use getOrgDomainUrl() in orgs with or without My Domain to retrieve canonical URLs. For example: https://yourDomain.my.salesforce.com, or, for orgs without My Domain enabled https://yourInstance.salesforce.com.

How do I get an org domain in Salesforce?

getOrgDomainUrl() . Returns the canonical URL for your org. For example, https://yourDomain.my.salesforce.com or, for orgs without My Domain enabled, https://yourInstance.salesforce.com . System.

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9