Use of deprecated URL.getSalesforceBaseUrl() method
Why is this an issue?
As of API version 59.0, URL.getSalesforceBaseUrl() is deprecated in favor of URL.getOrgDomainUrl(). Salesforce is replacing the legacy base URL semantics with My Domain–aware behavior, so existing calls may return unexpected URLs or stop working in a future API version.
Examples
Example of incorrect code:
String baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
String baseUrl = System.URL.getSalesforceBaseUrl().toExternalForm();
Url item = new Url('');
String baseUrl = item.getSalesforceBaseUrl().toExternalForm();
Example of correct code:
String baseUrl = URL.getOrgDomainUrl().toExternalForm();
How can I fix violations?
Replace URL.getSalesforceBaseUrl() with URL.getOrgDomainUrl(). Both return a Url object, so a .toExternalForm() call on the result continues to work unchanged.
Resources
