salesforcer icon indicating copy to clipboard operation
salesforcer copied to clipboard

Problem with `sf_run_report` Error: BAD_REQUEST: Groupings are not supported on a tabular report.

Open JacobNord opened this issue 4 years ago • 1 comments

Issue submission checklist

When filing your issue please make an attempt to troubleshoot a little bit on your own. If your issue is specifically related to a query, but please consider using the "Query issue template". Also, please consider some of the suggestions below before submitting an issue. Thank you!

  • [ YES] I have set verbose=TRUE function argument if possible.

  • [I DONT THINK THIS IS APPLICABLE] I have tried a few different function call arguments to see if I can workaround and/or isolate the issue (e.g. reviewing the output from the "SOAP" vs "REST" or the "Bulk 1.0" vs "Bulk 2.0" or tinkering with the control argument in the function call).

  • [ ] I have taken a look at the unit tests directory ./tests/testthat/ to see if my type of issue has been documented and tested.

  • [NO] I have considered making a minimal reproducible example using the reprex package. Details on how to create a reprex are available here: https://www.tidyverse.org/help/#reprex.

  • [ ] I have included the version of R and any packages that are used (Hint: Simply copy/paste the result of devtools::session_info() at the bottom of your issue).

Thank you for considering these steps. It will speed up the process of resolving your issue.


Issue description

A brief description of the problem.

Using sf_run_report, i put in the report id, but i get the error " Error: BAD_REQUEST: Groupings are not supported on a tabular report."

report_id <- "some string" results <- sf_run_report(report_id)

The report has a grouping value as a column. Are reports like that just not able to be pulled into R by this function?

reprex

# consider inserting a reprex here

Session Info

# consider inserting the output of devtools::session_info() here 
version  R version 4.0.3 (2020-10-10)
 os       Windows 10 x64              
 system   x86_64, mingw32

JacobNord avatar Aug 24 '21 18:08 JacobNord

@JacobNord Thanks for raising the issue! Yes, only tabular reports are supported at the moment. Since tabular reports don’t have groupings, all of the record level data and summaries are expressed by the T!T key, which refers to the grand total. There is a function parse_report_detail_rows() that you could attempt to modify to work with Summary and Matrix style reports that contain groupings. You will have to read the documentation on which fact map code to target in the report and then parse it.

https://github.com/StevenMMortimer/salesforcer/blob/aef7aeeabcfc736e859eb18e9bfa56cf0cd2c178/R/utils-report.R#L73

Here is some documentation from the API on how to determine what fact map key you'll want to use to get the results of interest: https://developer.salesforce.com/docs/atlas.en-us.api_analytics.meta/api_analytics/sforce_analytics_rest_api_factmap_example.htm

Side note: I will label this issue as a feature request, because over time I'd love to support Summary and Matrix style reports, I just haven't had the time to implement. If you figure it out, it would be awesome to open a PR and I'll incorporate into the package for others to use. Thanks again!

StevenMMortimer avatar Sep 03 '21 13:09 StevenMMortimer