1

I'm trying to do an ad-hoc cleaning exercise to see how many reports in Salesforce.com use a given custom report type. The goal is to find custom report types that are deployed, but have no reports built off of them.

Since the report object doesn't have the ReportType attribute, I'd like to use Simple-Python to query the analytics API to get a full list of every report in my system, then I can use the returned describeUrl to get the report type information.

The issue is that I can't seem to figure out how to get a full list of results from the API. The rest path works fine in workbench, but doesn't work in Python. Any help would be greatly appreciated.

from simple_salesforce import Salesforce

sf = Salesforce(username = '[email protected]', password = 
'mypassword', security_token = 'mysecuritytoken', sandbox = 
True, client_id = 'Report Query')

# just trying to get a json response of all reports - once I have the data 
set returned I can complete my script
# and parse through the result details

query_results = sf.query("/services/data/v39.0/analytics/reports")

print(query_results)

1 Answer 1

1

You can query the Report Object:

x= sf.query("SELECT Id, Name FROM Report")
for item in x['records']:

    print item['Name'], item['Id']

available fields and methods are here (Salesforce documentation)

Or you can do a SOQL on other Objets related to reports to get the data you need using the above code sample.

2
  • Thanks glls, appreciate the input. It looks like there is no way to do a SOQL query on the ReportType object, which is what I really need. With your query I can get the full list of reports and their ID's which is very helpful, but I would still need to structure a loop to get corresponding report types from the describeUrl: "/services/data/v39.0/analytics/reports/<returnedReportIdHere/describe" Do you by chance have any idea how to structure that get request with Simple-Python?
    – Tom Kline
    Apr 10, 2017 at 20:52
  • 1
    Hi tom, sry for the late post. you could use the requests library which is documented here docs.python-requests.org/en/master in order to do the api calls you need, once you have fetched the id's using simple-python you can/should be able to ping the url. here is another useful post on going about pinging salesforce using the request library wadewegner.com/2013/11/forcecom-token-requests-with-python
    – glls
    Apr 13, 2017 at 21:46

You must log in to answer this question.

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