0

How can I check if an object has records using Python? I only know the object api name and label. I don't know its field names.

The answer may be a boolean or a list of record ID's.

3
  • 2
    What about a record count?
    – sfdcfox
    Commented Apr 6, 2022 at 21:55
  • 1
    Are you using simple_salesforce or SalesforcePy or something else? Have you tried anything?
    – David Reed
    Commented Apr 6, 2022 at 22:55
  • I'm using simple_salesforce. I tried the following: pd.DataFrame(sf.query("SELECT name FROM Account")['records']). The problem is that not every object has a field "name". What's the api call for record count? could you show an example line of code?
    – ThaNoob
    Commented Apr 7, 2022 at 7:13

1 Answer 1

0

I was using the wrong google search terms apparently. Using the search term mentioned in the comment of sfdcfox I stumbled upon this post.

Which led to the following simple lines of code which prints an int with the amount of records:

obj_info = sf.query("SELECT COUNT() FROM Account")
print(obj_info['totalSize'])

You must log in to answer this question.

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