Is there an easy way to get the SF instance (i.e., "NA14")?

  • 1
  • Question
  • Updated 4 years ago
  • Answered
I think because of our custom domain and the fact that we are using a portal, our custom Skuid button for a third-party product (DrawlLoop) needs to "get" the instance of Salesforce we are on and pass it via the URL. Is there an easy way to do that? I'm hoping it's in the Skuid API somewhere so that I don't have to either a) hardcode it, or b) parse the URL.
Photo of Peter Bender

Peter Bender, Champion

  • 6,246 Points 5k badge 2x thumb

Posted 5 years ago

  • 1
Photo of Brandon Klapholz

Brandon Klapholz

  • 390 Points 250 badge 2x thumb
Have you tried generating the button using Drawloop's button generator tool, and then exposing it like via Skuid from the dropdown like you would for any other page button?
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
The short answer is no, there is no reliable, easy way to get the SF instance, particularly in an org with My Domain enabled, without parsing the URL of a Visualforce Page.

However, in Salesforce Summer 14 they are exposing an "InstanceName" field on the Organization object, so you could create a Model on the Organization object to pull in the current Organization and grab the Instance Name off of that, then in your Redirect URL's for launching an app like Drawloop  you could do:

/apex/drawloop__DoStuff?myinstance={{$Model.Organization.data.0.InstanceName}}

But this won't be available until July. In the meantime, hardcoding the Instance Name is probably the easiest approach, or else you're going to have to parse the URL of the current Visualforce Page you're on.