View source: R/analytics-report.R
sf_run_report | R Documentation |
This function is a convenience wrapper for retrieving the data from a report.
By default, it executes an asynchronous report and waits for the detailed data
summarized in a tabular format, before pulling them down and returning as a
tbl_df
.
sf_run_report( report_id, report_filters = NULL, report_boolean_logic = NULL, sort_by = character(0), decreasing = FALSE, top_n = NULL, async = TRUE, interval_seconds = 3, max_attempts = 200, wait_for_results = TRUE, guess_types = TRUE, bind_using_character_cols = deprecated(), fact_map_key = "T!T", verbose = FALSE )
report_id |
|
report_filters |
|
report_boolean_logic |
|
sort_by |
|
decreasing |
|
top_n |
|
async |
|
interval_seconds |
|
max_attempts |
|
wait_for_results |
|
guess_types |
|
bind_using_character_cols |
|
fact_map_key |
|
verbose |
|
This function is essentially a wrapper around sf_execute_report
.
Please review or use that function and/or sf_query_report
if you
want to have more control over how the report is run and what format should
be returned. In this case we've forced the reportFormat="TABULAR"
without total rows and given options to filter, and select the Top N as
function arguments rather than forcing the user to create an entire list of
reportMetadata
.
tbl_df
Below are the fact map key patterns for three report types:
T!T
: The grand total of a report. Both record data
values and the grand total are represented by this key.
<First level row grouping_second level row grouping_third
level row grouping>!T
: T refers to the row grand total.
<First level row grouping_second level row grouping>!<First
level column grouping_second level column grouping>.
Each item in a row or column grouping is numbered starting with 0. Here are some examples of fact map keys:
The first item in the first-level grouping.
The second item in the first-level grouping.
The first item in the first-level grouping and the first item in the second-level grouping.
The first item in the first-level grouping and the second item in the second-level grouping.
Other Report functions:
sf_copy_report()
,
sf_create_report()
,
sf_delete_report()
,
sf_describe_report_type()
,
sf_describe_report()
,
sf_execute_report()
,
sf_list_report_fields()
,
sf_list_report_filter_operators()
,
sf_list_report_types()
,
sf_list_reports()
,
sf_query_report()
,
sf_update_report()
## Not run: # find a report in your org and run it all_reports <- sf_query("SELECT Id, Name FROM Report") this_report_id <- all_reports$Id[1] results <- sf_run_report(this_report_id) # apply your own filters to that same report # set up some filters, if needed # filter records that was created before this month filter1 <- list(column = "CREATED_DATE", operator = "lessThan", value = "THIS_MONTH") # filter records where the account billing address city is not empty filter2 <- list(column = "ACCOUNT.ADDRESS1_CITY", operator = "notEqual", value = "") # combine filter1 and filter2 using 'AND' so that records must meet both filters results_using_AND <- sf_run_report(my_report_id, report_boolean_logic = "1 AND 2", report_filters = list(filter1, filter2)) # combine filter1 and filter2 using 'OR' which means that records must meet one # of the filters but also throw in a row limit based on a specific sort order results_using_OR <- sf_run_report(my_report_id, report_boolean_logic = "1 OR 2", report_filters = list(filter1, filter2), sort_by = "Contact.test_number__c", decreasing = TRUE, top_n = 5) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.