I have created the new order record in salesforce,for Particular Record, owner field is updated with the username who created the order record

I want to take the instance of salesforce organization with the help of Owner name

for example owner of the record is somename

i want to take the current instance of the somename https://getinstance.salesforce.com with the help of ownername

How? Please anyone Guide me for the Answer

I have tried Like this: {!$orderOwner.getinstancename()}/{!$userid} but it is not working Guide Me the answer


You can query your current Salesforce.com instance from Apex code:

String instance = System.URL.getSalesforceBaseUrl().getHost();

enter image description here

This will give you complete host name, you will need to break it using any string method to get the exact instance name.

VF Page

<apex:page docType="html-5.0" controller="myController"  >
  <apex:form id="form1">
      <br />
      <apex:outputText id="urlString" value="{!url}"></apex:outputText>


public class myController {
    public string url{
        get {
            if (this.url == null)
                this.url = System.URL.getSalesforceBaseUrl().getHost();
            return this.url; }

  • i want with the help of owner name of the particular record to get the instance @mahmood – SFDC Oct 26 '16 at 11:06
  • Instance will remain the same in the org, regardless of the owner of any record whatsoever. May be, it will be clearer for us and be able to help you better if you share your requirements in detail here. – Mahmood Oct 26 '16 at 11:10
  • i want to access in the visualforce page code How?salesforce.stackexchange.com/questions/145988/… @mahmood – SFDC Oct 26 '16 at 11:12
  • can you guide me for that @Mahmood – SFDC Oct 26 '16 at 11:15
  • Do you have controller in you VF page? if yes, create a property and set it with the instance name you are looking for, then 'get' that property in your VF page. – Mahmood Oct 26 '16 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.