[Experimental]

Create a new report using a POST request. To create a report, you only have to specify a name and report type to create a new report; all other metadata properties are optional. It is recommended to use the metadata from existing reports pulled using sf_describe_report as a guide on how to specify the properties of a new report.

sf_create_report(
  name = NULL,
  report_type = NULL,
  report_metadata = NULL,
  verbose = FALSE
)

Arguments

name

character; a user-specified name for the report.

report_type

character; a character representing the type of report to retrieve the metadata information on. A list of valid report types that can be created using this function will be available in the reportTypes.type column of results returned sf_list_report_types. (e.g. AccountList, AccountContactRole, OpportunityHistory, etc.)

report_metadata

list; a list representing the properties to create the report with. The names of the list must be one or more of the 3 accepted metadata properties: reportMetadata, reportTypeMetadata, reportExtendedMetadata.

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

list representing the newly cloned report with up to 4 properties that describe the report:

attributes

Report type along with the URL to retrieve common objects and joined metadata.

reportMetadata

Unique identifiers for groupings and summaries.

reportTypeMetadata

Fields in each section of a report type plus filter information for those fields.

reportExtendedMetadata

Additional information about summaries and groupings.

Salesforce Documentation

Examples

if (FALSE) {
# creating a blank report using just the name and type
my_new_report <- sf_create_report("Top Accounts Report", "AccountList")

# creating a report with additional metadata by grabbing an existing report
# and modifying it slightly (only the name in this case)

# first, grab all possible reports in your Org
all_reports <- sf_query("SELECT Id, Name FROM Report")

# second, get the id of the report to copy
this_report_id <- all_reports$Id[1]

# third, pull down its metadata and update the name
report_describe_list <- sf_describe_report(this_report_id)
report_describe_list$reportMetadata$name <- "TEST API Report Creation"

# fourth, create the report by passing the metadata
my_new_report <- sf_create_report(report_metadata=report_describe_list)
}