How to get Salesforce Org Instance name dynamically?
You might come across a requirement where you have to get the instance name of the organisation.
In that case we can make use of one of the setup object in Salesforce and get access to the instance name.
This is how the query is gonna look like to get the instance name.
String instanceName = [SELECT InstanceName FROM Organization LIMIT 1].InstanceName;