I need to upgrade the metadata in post install script, for instance, upgrade the picklist values for some fields, as those values are not updatable for the existing orgs. Not matter I tried to use ToolingAPI or Metadata API, I was asked to specified the instance url in the remote site settings, otherwise, the endpoint is invalid. Do I have to add the instance url in each of the orgs, or is there any way to bypass this limit? Ideally, I don't want to add that in the remote site settings, as the instance url could be changed in case Salesforce does split in the future.
2 Answers
One method an evangelist told me about was to use a proxy, e.g. on heroku. So you callout goes every time to the same endpoint. Add the instance where your org is located to the request and the proxy is doing the final callout to the appropriate endpoint at salesforce again.
So you would only need one remote site which is the same for all orgs.
For my taste not good, because it won't make things faster and in all my scenarios I am counting each second to save...
As I said above, you can never add all possible endpoint for the all users, because of the myDomains.
What we did in the end is to add a couple of common endpoints to the package (like naXX,euXX,csXX) - but be even careful with that, because if you add to many, the confirm button will slide outside visible screen - and there are no scrollbars to reach it...
I believe you can specify one instance url, say na1, and use that as your endpoint. SF will auto-reroute the request to the proper instance that you're logged into.
-
unfortunately, it seems that way doesn't work. I tried add na1.salesforce.com as Remote Site URL, Endpoint=na1.salesforce.com/services/data/v30.0/tooling/sobjects/…{ID} , got exception:the System.HttpResponse[Status=Unauthorized, StatusCode=401]– DavidCommented Jul 2, 2014 at 18:28
-
1While the browser is nice enough to do this for you, the API isn't as forgiving. You will indeed need to add all possible URL values to the list of remote site settings, and include this in your package. Otherwise, you'll need to provide manual upgrade steps or pre-installation steps.– sfdcfox ♦Commented Jul 2, 2014 at 18:42
-
Providing all possible endpints is not possible. Think about the myDomains. If you try to provide a very long list of remote sites for the standard pods, you will also end up in scrolling issues and confirm button outside visible screen.– Uwe HeimCommented Jul 2, 2014 at 20:00
-
You're right. I did forget about my domain. Manual step or proxy it is.– sfdcfox ♦Commented Jul 10, 2014 at 21:32