View source: R/create-metadata.R
sf_create_metadata | R Documentation |
This function takes a list of Metadata components and sends them to Salesforce for creation
sf_create_metadata( metadata_type, metadata, control = list(...), ..., all_or_none = deprecated(), verbose = FALSE )
metadata_type |
|
metadata |
|
control |
|
... |
arguments passed to |
all_or_none |
|
verbose |
|
A tbl_df
containing the creation result for each submitted metadata component
## Not run: # read the metadata of the existing Account object # we will use this object as a template to create a custom version metadata_info <- sf_read_metadata(metadata_type='CustomObject', object_names=c('Account')) custom_metadata <- metadata_info[[1]] # remove default actionOverrides, this cannot be set during creation custom_metadata[which(names(custom_metadata) %in% c("actionOverrides"))] <- NULL # remove fields since its a custom object and the standard ones no longer exist custom_metadata[which(names(custom_metadata) %in% c("fields"))] <- NULL # remove views so that we get the Standard List Views custom_metadata[which(names(custom_metadata) %in% c("listViews"))] <- NULL # remove links so that we get the Standard Web Links custom_metadata[which(names(custom_metadata) %in% c("webLinks"))] <- NULL # now make some adjustments to customize the object this_label <- 'Custom_Account43' custom_metadata$fullName <- paste0(this_label, '__c') custom_metadata$label <- this_label custom_metadata$pluralLabel <- paste0(this_label, 's') custom_metadata$nameField <- list(displayFormat='AN-{0000}', label='Account Number', type='AutoNumber') custom_metadata$fields <- list(fullName="Phone__c", label="Phone", type="Phone") # set the deployment status, this must be set before creation custom_metadata$deploymentStatus <- 'Deployed' # make a description to identify this easily in the UI setup tab custom_metadata$description <- 'created by the Metadata API' new_custom_object <- sf_create_metadata(metadata_type = 'CustomObject', metadata = custom_metadata, verbose = TRUE) # adding custom fields to our object # input formatted as a list custom_fields <- list(list(fullName='Custom_Account43__c.CustomField66__c', label='CustomField66', length=100, type='Text'), list(fullName='Custom_Account43__c.CustomField77__c', label='CustomField77', length=100, type='Text')) # formatted as a data.frame custom_fields <- data.frame(fullName=c('Custom_Account43__c.CustomField88__c', 'Custom_Account43__c.CustomField99__c'), label=c('Test Field1', 'Test Field2'), length=c(44,45), type=c('Text', 'Text')) new_custom_fields <- sf_create_metadata(metadata_type = 'CustomField', metadata = custom_fields) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.