sf_get_report_instance_results: Get report instance results

View source: R/analytics-report.R

sf_get_report_instance_resultsR Documentation

Get report instance results

Description

[Experimental]

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 value 0016A0000035mJEQAY. The former (label) more accurately reflects the "Account.Name".

guess_types

logical; indicating whether or not to use col_guess() to try and cast the data returned in the recordset. If TRUE then col_guess() is used, if FALSE then all fields will be returned as character. This is helpful when col_guess() will mangle field values in Salesforce that you'd like to preserve during translation into a tbl_df, like numeric looking values that must be preserved as strings ("48.0").

bind_using_character_cols

logical; an indicator of whether to cast the data to all character columns to ensure that bind_rows does not fail because two paginated recordsets have differing datatypes for the same column. Set this to TRUE rarely, typically only when having this set to FALSE 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 the reportFormat 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 to TRUE 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.

Salesforce Documentation

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

## Not run: 
# 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)
}

## End(Not run)

salesforcer documentation built on March 18, 2022, 6:26 p.m.