Module: SfCli::Sf::Data::UpdateRecord

Included in:
Core
Defined in:
lib/sf_cli/sf/data/update_record.rb

Instance Method Summary collapse

Instance Method Details

#update_record(object_type, record_id: nil, where: nil, values: nil, target_org: nil) ⇒ Object

update a object record.

object_type — Object Type (ex. Account)

record_id — id of the object

where — field values that is used to identify a record

values — field values for update

target_org — an alias of paticular org, or username can be used

examples

sf.data.update_record :Account, record_id: 'xxxxxxx', values: {Name: 'New Account Name'}
sf.data.update_record :Hoge__c, where: {Name: 'Jonny B.Good', Country: 'USA'}, values: {Phone: 'xxxxx', bar: 2000}

For more command details, see the command reference



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/sf_cli/sf/data/update_record.rb', line 22

def update_record(object_type, record_id: nil, where: nil, values: nil, target_org: nil)
  where_conditions  = field_value_pairs(where)
  field_values      = field_value_pairs(values)
  flags = {
    :"sobject"    => object_type,
    :"record-id"  => record_id,
    :"where"      => (where_conditions.nil? ? nil : %|"#{where_conditions}"|),
    :"values"     => (field_values.nil? ? nil : %|"#{field_values}"|),
    :"target-org" => target_org,
  }
  action = __method__.to_s.tr('_', ' ')
  json = exec(action, flags: flags, redirection: :null_stderr)

  json['result']['id']
end