1

I want to programmatically create a report with several filters, and I'm not sure how to correctly do this via Report API.

Note : The report type (objects returned in the report) are dynamically chosen by the user, so I don't know in advance whether this is going to be a report on Leads \ Opportunities \ Accounts \ Custom object etc.

My options as far as I see :

  • Use the QUERY method to run a report - but then, how can I save this report for later use? (Documentation says it's not saved)

  • Create a dummy report manually, then use PATCH method to change an existing report - tried this, but it seems I cannot change the reportType field (I get an error saying "INVALID COLUMN" when trying to change an Opportunities report to a Leads Report)

Am I missing something?

  • An Opportunities Report will have different fields in it than a Leads Report. – crmprogdev Sep 26 '16 at 12:58
  • You're right, but even after changing both list of columns and report types I get this error. – Yossi Vainshtein Sep 26 '16 at 13:11
  • I think you need Metadata API - metadata type = Report; see developer.salesforce.com/docs/atlas.en-us.api_meta.meta/… and also the Apex wrapper to the metadata API. However, running user will need Setup and Change application permissions which would not be a good idea. Why not just use Dynamic SOQL and VF? – cropredy Oct 2 '16 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.