3

I need to get the server-name via JS (running in a custom link / execute JavaScript).

The link is provided by a managed package (packageA) and needs to figure out the server-name to be able to construct an URL navigation to a VF-Page of an other managed package (packageB).

I can't let the link point directly to the VF-Page because:

  • making the packages dependent isn't possible. The packages (A and B) needs to be installed/uninstalled independently from each other. Only the link provided by packageA should break if packageB isn't there
  • I need to submit dynamically extra URL-parameters via the link as URL params e.g. like this https://packageB.eu1.visual.force.com?p1=foo&p2=bar

So my goal is to construct a string like this https://packageB.eu1.visual.force.com?p1=foo&p2=bar. I know all the tokens but "eu1" (the pod name). I can parse it out of the current URL but only if no MyDomains are used in the residing Org. The usage of MyDomain masks the pod-name.

Any ideas?

I noticed that for myDomains the needed URL would be

https://MyDomainName--packageB.eu1.visual.force.com/apex/VFPageName

From any Standard URL I can figure the MyDomain Name easily out of the residing URL of the Link e.g. https://MyDomainName.my.salesforce.com/anyStandardURLhere. Also I noticed the MyDomain prefix is optional. Omitting it forwards automatically to the prefixed URL.

Still I'm missing the pod-name.

2

It's not a very elegant solution, but you could create (and then delete) an object using JavaScript, capture the ID of the created object and process the POD name using the mapping method detailed at Converting the Salesforce Pod Id to ServerUrl/Name

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.