Find your Salesforce Instance using SOQL
130 views
Jun 9, 2025
Blog Post: https://www.infallibletechie.com/2022/10/how-to-find-your-salesforce-instance-using-soql.html
View Video Transcript
0:04
foreign
0:09
in this video we are going to see how to
0:13
find
0:14
Salesforce instance name using soql
0:19
if we go to company information
0:22
in setup
0:25
you can find your Salesforce
0:28
organization ID and your Edition
0:31
and
0:32
your instance
0:35
so this is instance
0:38
can be queried also
0:41
using a simple soql we can query the
0:45
instance name
0:47
there are
0:48
activities for example site switch or
0:52
Arc migration as part of it our instance
0:56
may change
0:58
especially for Arc migration the
1:00
instance name will change since uh
1:03
Salesforce upgrades us to a better
1:06
infrastructure
1:09
server so during that time the instance
1:13
name varies so if you have any
1:18
integration or any third party
1:20
application using the instance name
1:22
instead of hard coding you can use this
1:26
srql
1:27
so first let's run this soql
1:31
from developer console so select ID
1:34
comma instance name from organization
1:38
so organization is an entity where the
1:41
instance name is stored
1:45
so this is my org ID 18 digit Target ID
1:47
and this is the instance name
1:50
so this is the org ID and this is the
1:52
instance name so this is 15 digit
1:55
and this is 18 digit ID and this is the
1:59
instance name
2:00
so let's say you have a third party
2:02
application where you have some
2:04
integration and then you wanted to query
2:06
it
2:07
so using Postman let me show you that
2:10
so here
2:12
first you have to do a post request to
2:15
slash Services slash or2 slash token and
2:19
in the body you have to pass your
2:21
username password you should have a
2:24
Connected app and from the Connected app
2:27
you have to get the consumer key and
2:29
consumer secret and the grant type
2:31
should be password so using this post
2:35
ah operation we will be able to get the
2:38
access token first
2:41
so I got the access token currently the
2:44
access token is stored in a variable in
2:46
within my Postman
2:48
so if you go to
2:50
headers I have this access token Banner
2:54
space access token so the authorization
2:57
value should be Banner space this access
3:00
token
3:03
so once you have it
3:05
you can use slash Services slash data
3:09
slash version number slash query and you
3:12
have to use get method here so the query
3:16
parameter
3:17
you can pass the
3:19
query select ID comma instance name from
3:22
organization
3:24
and in the headers you have to use
3:26
authorization as the key and the value
3:29
should be Bearer space the access token
3:32
which we got it from the
3:34
post call
3:37
so now if you run it
3:40
it will return your organization details
3:43
so this is the ID and this is the
3:46
instance name
3:47
so it will return in Json so you can
3:49
parse it using your third party
3:53
application and then you can get the
3:54
instance name
3:56
so using select ID comma instance name
3:59
from organization in DD we can easily
4:02
query the Salesforce
4:05
instance name
4:08
this will avoid hard coding the instance
4:11
name and we can dynamically get the
4:13
instance name
4:26
I hope it was helpful
4:41
thank you for watching
#Computers & Electronics
#Internet & Telecom
#Internet Software