0

Before you point me to LIKE Clause documentation, I already read it.

I created new custom object thats API name is TestObject__c.

Now I would like to query my custom objects. So I need to find the ones that end with "__c".

LIKE '%\_\_c'

SELECT QualifiedApiName FROM EntityDefinition WHERE QualifiedApiName LIKE '%\_\_c' ORDER BY QualifiedApiName

Escaping underscore (_) with backslash (\) is not working as expected.

I tried a lot of variations but nothing works. I get 0 objects in result. When I do not escape underscores, I get 14 objects (1 custom, 13 standard), basically all ending with "c".

I tested this in Developer Console.

1 Answer 1

0

The better approach here is to filter based on the key prefix.

Custom objects always start with 'a', starting with 'a00'. There's a nifty Salesforce help article that lists all of the prefixes used.

SELECT QualifiedApiName FROM EntityDefinition WHERE KeyPrefix LIKE 'a%'

2
  • Works! Thank you very much Derek :)
    – Vergil333
    Mar 16, 2022 at 19:35
  • I got hard question - is there a way to query just list of objects that can be queried alone? On AccountChangeEvent I'm getting error message "entity type AccountChangeEvent does not support query".
    – Vergil333
    Apr 22, 2022 at 18:33

You must log in to answer this question.

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