我刚刚发现了强制cli工具。如何查询超过2000条记录?
我让它为查询工作,但它只返回2000,我需要全部解决。
force query select Id, Name from Custom_Object__c --format:csv > custom.csv
这个文件有大约10,000条记录,我只能得到第一个2000. cli工具的文档没有提到很多细节,但它比我使用的工具快得多,哪个R使用RForcecom库
答案 0 :(得分:0)
您需要做的就是使用包bulkQuery
中的RForcecom
功能。例如:
all_leads <- "SELECT Id FROM Lead WHERE CreatedDate < TODAY"
rforcecom.bulkQuery(rforce_session, all_leads,object="Lead") -> all_leads_df
为今天之前Id
中的所有内容选择Lead
。花大约一分钟让我做~70万行。
答案 1 :(得分:0)
salesforcer软件包可以通过Bulk 1.0 API快速查询数百万条记录。下面是一个示例,该示例返回Contact对象上的所有记录和字段:
library(tidyverse)
library(salesforcer)
sf_auth(username, password, security_token)
# get all the fields on the Contact object (remove compound fields which
# are not queryable via the Bulk API.
# https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/compound_fields.htm
contact_fields <- sf_describe_object_fields('Contact') %>%
filter(type != 'address', !grepl('Latitude|Longitude', name))
# build the SOQL
all_soql <- sprintf("SELECT %s FROM Contact",
paste(contact_fields$name, collapse=","))
# query the records and fields
all_records <- sf_query(all_soql, "Contact", api_type="Bulk 1.0")
all_records
#> # A tibble: 2,039,230 x 58
#> Id IsDeleted MasterRecordId AccountId ...
#> <chr> <lgl> <lgl> <lgl>
#> 1 0033s00000wycyeAAA FALSE NA NA
#> 2 0033s00000wycyjAAA FALSE NA NA
#> 3 0033s00000wycyoAAA FALSE NA NA
#> # ...