Is it possible to SOQL Salesforce for a Record Name without knowing the object name?

I will only know the of the record not the ID or Object unfortunately.

  • Thanks guys I looked into that but... This is essentially for integration in which I will only have a record name where there are no look ups and no ID.....
    – CodeMonger
    Commented May 15, 2019 at 13:16
  • Is it possible to use the Global Search somehow?? Such as UnifiedSearchResults?searchType through code?
    – CodeMonger
    Commented May 15, 2019 at 13:19
  • Have you taken a look at search for string rest api, if that helps?
    – Jayant Das
    Commented May 15, 2019 at 13:25

4 Answers 4


On top of SOSL searches which can find a search string across different entities, e.g.,

FIND {MyRecordName}

which returns the IDs of the records where text is found, you can also utilize REST API here.

If you are open to use REST API, you can utilize the Search for a String here. This will allow you to achieve your use case to just provide the record name and no object details. The result in return will provide you the details as which records consist of the search string. You can find more details on the documentation.

A note here, even though the docs doesn't mention which fields are returned in this search, but it always returns results on matching Name field on different objects (I confirmed this with a test).

So your sample request will look like as below.

Using SOSL Search:


Using Parameterized Search:


And response will look as:

    "searchRecords": [
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v43.0/sobjects/Contact/xxxx"
            "Id": "xxxx"
            "attributes": {
                "type": "Account",
                "url": "/services/data/v43.0/sobjects/Account/xxxx"
            "Id": "xxxx"

SOSL lets you search multiple objects to find matching data. An example search might look like:


If you do know some objects you want to limit it to, you could add them as follows:

FIND 'Doe' IN NAME FIELDS RETURNING Account, Contact, User
  • I like it but I would have to know the object name.
    – CodeMonger
    Commented May 15, 2019 at 13:14
  • If you don't know which objects you even want to check, you're out of luck, barring some complicated code implementation.
    – Adrian Larson
    Commented May 15, 2019 at 13:26
  • According to the SOSL examples, it should be possible to search any object: 'Look for joe anywhere in the system. Return the IDs of the records where joe is found.' FIND {joe} developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/…
    – Folkert
    Commented May 15, 2019 at 13:38
  • Hmm, it didn't work when I tried it initially, but it may be that the search term simply wasn't found. I'll update accordingly.
    – Adrian Larson
    Commented May 15, 2019 at 13:41

You should probably Use a SOSL for the above use case.



No, the documentation on SOQL syntax provides the structure needed for valid queries

SELECT fieldList [subquery][...]
[TYPEOF typeOfField whenExpression[...] elseExpression END][...]
FROM objectType[,...] 
    [USING SCOPE filterScope]
[WHERE conditionExpression]
[WITH [DATA CATEGORY] filteringExpression]
[GROUP BY {fieldGroupByList|ROLLUP (fieldSubtotalGroupByList)|CUBE (fieldSubtotalGroupByList)} 
    [HAVING havingConditionExpression] ] 
[LIMIT numberOfRowsToReturn]
[OFFSET numberOfRowsToSkip]
[FOR {VIEW  | REFERENCE}[,...] ]

the clause description for objecttype states the following:

Specifies the type of object that you want to query(). You must specify a valid object...

some of the optional ones would be:


  • Not everything that is there is required, and which is what might be non-obvious to the untrained eye.
    – Adrian Larson
    Commented May 15, 2019 at 13:32
  • true, the doc does state some of the optional ones, updating accordingly
    – glls
    Commented May 15, 2019 at 13:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .