2

I'm trying to retrieve object descriptions with the following SQL query:

obj_info = pd.DataFrame(sf.query(
        "SELECT Label, Description FROM EntityDefinition WHERE IsCustomizable=True")[
                                              'records'])

Somehow he doesn't want to extract the description although according to the docs it should be part of the EntityDefinition object.

2 Answers 2

4

You need to use toolingexecute method from simple_salesforce for your use case.

from simple_salesforce import Salesforce
import pandas as pd

def queryWithToolingAPI():
    sf = Salesforce(instance_url='https://******--****.my.salesforce.com', session_id='00D0k0000009c**************PLzvO7pDsVFfuqwgAz')
    obj_info = pd.DataFrame(sf.toolingexecute("query/?q=SELECT+Label,Description+from+EntityDefinition+Where+IsCustomizable=True")['records'])
    print(obj_info)


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    queryWithToolingAPI()

As the EntityDefinition's Description is only available via Tooling API.

From Docs:

This field is available in Tooling API version 34.0 and later. Because this field represents a relationship, use only in subqueries.

3
  • Thank you for the reply. That was indeed the issue. One question: Why are you passing the 'PyCharm' string to the function? It seems to have no use.
    – ThaNoob
    Apr 8, 2022 at 6:15
  • That leave it, I modified existing code snippet which my IDE gives . and forgot to remove it. Will remove it now. Apr 8, 2022 at 6:19
  • In the hope it may one day save someone 2 hours of frustration: The tooling API retrieves some additional objects, some of which don't have a "DataType" column for example.
    – ThaNoob
    Apr 8, 2022 at 8:58
3

Make sure you are using the tooling API to execute the query.

If you are using regular SOAP or REST the description field may not be applicable

2
  • 1
    Your answer is correct, but I accepted Nagendra's answer as it is more detailed.
    – ThaNoob
    Apr 8, 2022 at 6:12
  • @ThaNoob Fair enough :) Apr 8, 2022 at 6:12

You must log in to answer this question.

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