Module: SfCli::Sf::Data::UpsertBulk
- Included in:
- Core
- Defined in:
- lib/sf_cli/sf/data/upsert_bulk.rb
Instance Method Summary collapse
-
#upsert_bulk(file:, sobject:, external_id:, timeout: nil, target_org: nil) ⇒ Object
update records using Bulk API 2.0.
Instance Method Details
#upsert_bulk(file:, sobject:, external_id:, timeout: nil, target_org: nil) ⇒ Object
update records using Bulk API 2.0
file — a CSV file for update records
sobject — Object Type (ex. Account)
external_id — Name of the external ID field, or the Id field
timeout — max minutes to wait for the job complete the task.
target_org — an alias of paticular org, or username can be used
# start a upsert job
jobinfo = sf.data.upsert_bulk sobject: :TestCustomObject__c, file: 'upsert.csv' # this returns immediately
jobinfo.id # => "750J4000003g1OaIAI" it's job ID
# you can check if the upsert job completed
sf.data.upsert_resume job_id: jobinfo.id
# Or, you can wait for the job completion with one try.
result = sf.data.upsert_bulk sobject: :TestCustomObject__c, file: 'upsert.csv', timeout: 5 # wait within 5 minutes
For more command details, see the command reference
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/sf_cli/sf/data/upsert_bulk.rb', line 30 def upsert_bulk(file:, sobject:, external_id:, timeout: nil, target_org: nil) flags = { :"file" => file, :"sobject" => sobject, :"external-id" => external_id, :"wait" => timeout, :"target-org" => target_org, } action = __method__.to_s.tr('_', ' ') json = exec(action, flags: flags, redirection: :null_stderr) job_info = ::SfCli::Sf::Data::JobInfo.new(**json['result']['jobInfo']) return job_info unless json['result']['records'] ::SfCli::Sf::Data::BulkResultV2.new( job_info: job_info, records: ::SfCli::Sf::Data::BulkRecordsV2.new(**json['result']['records']) ) end |