You need to sign in to do that
Don't have an account?
Want to remove Hardcoded URL from the apex code
Hi,
I am using a hardcoded URL 'https://na1.salesforce.com/' in the code of trigger which appends this URL with a particualr record Id and Posts it in a chatter message. But now, we are moving our organisation from 'na1' server instance to other server instance. So, I want some alternative mechanism that can be used in place of hardcoded server URL so that, in future if we again move our server instance than there is no need to change the server instance in the url.
I tried using https://login.salesforce.com/ and /recordId instead of https://na1.salesforce.com/, but they do not appear to work. They redirect the user to the Salesforce login page.
Thanks
Hi,
Try the below code that will give you dynamic url according to org.
string url= URL.getSalesforceBaseUrl();
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.