Retrieves results for an instance of a report run asynchronously with or without filters. Depending on your asynchronous report run request, data can be at the summary level or include details.
Usage
sf_get_report_instance_results(
report_id,
report_instance_id,
labels = TRUE,
guess_types = TRUE,
bind_using_character_cols = deprecated(),
fact_map_key = "T!T",
verbose = FALSE
)
Arguments
- report_id
character
; the Salesforce Id assigned to a created analytics report. It will start with"00O"
.- report_instance_id
character
; the Salesforce Id assigned to a created analytics report instance (an asynchronous run). It will start with"0LG"
.- labels
logical
; an indicator of whether the returned data should be the label (i.e. formatted value) or the actual value. By default, the labels are returned because these are what appear in the Salesforce dashboard and more closely align with the column names. For example, "Account.Name" label may be"Account B"
and the value0016A0000035mJEQAY
. The former (label) more accurately reflects the "Account.Name".- guess_types
logical
; indicating whether or not to usecol_guess()
to try and cast the data returned in the recordset. IfTRUE
thencol_guess()
is used along withanytime()
andanydate()
. IfFALSE
then all fields will be returned as character. SpecifyingFALSE
helpful when guessing the column data type will result in NA values and you would like to return the results as strings and then cast in your script according to your unique specifications.- bind_using_character_cols
logical
; an indicator of whether to cast the data to all character columns to ensure thatbind_rows
does not fail because two paginated recordsets have differing datatypes for the same column. Set this toTRUE
rarely, typically only when having this set toFALSE
returns an error or you want all columns in the data to be character.- fact_map_key
character
; string providing an index into each section of a fact map, from which you can access summary and detailed data. The pattern for the fact map keys varies by report format so it is important to know what thereportFormat
property of the target report is. See the note below for more details.- verbose
logical
; an indicator of whether to print additional detail for each API call, which is useful for debugging. More specifically, when set toTRUE
the URL, header, and body will be printed for each request, along with additional diagnostic information where available.
Value
tbl_df
; the detail report data. More specifically, the detailed
data from the "T!T" entry in the fact map.
Note
Below are the fact map key patterns for three report types:
- TABULAR
T!T
: The grand total of a report. Both record data values and the grand total are represented by this key.- SUMMARY
<First level row grouping_second level row grouping_third level row grouping>!T
: T refers to the row grand total.- MATRIX
<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:
- 0!T
The first item in the first-level grouping.
- 1!T
The second item in the first-level grouping.
- 0_0!T
The first item in the first-level grouping and the first item in the second-level grouping.
- 0_1!T
The first item in the first-level grouping and the second item in the second-level grouping.
See also
Other Report Instance functions:
sf_delete_report_instance()
,
sf_list_report_instances()
Examples
if (FALSE) { # \dontrun{
# execute a report asynchronously in your Org
all_reports <- sf_query("SELECT Id, Name FROM Report")
this_report_id <- all_reports$Id[1]
results <- sf_execute_report(this_report_id, async=TRUE)
# check if that report has succeeded, ...
instance_list <- sf_list_report_instances(this_report_id)
instance_status <- instance_list[[which(instance_list$id == results$id), "status"]]
# ... if so, then grab the results
if(instance_status == "Success"){
report_data <- sf_get_report_instance_results(report_id = this_report_id,
report_instance_id = results$id)
}
} # }