Module: SfCli::Sf::Data::DeleteRecord

Defined in:
lib/sf_cli/sf/data/delete_record.rb

Instance Method Summary collapse

Instance Method Details

#delete_record(object_type, record_id: nil, where: nil, target_org: nil, api_version: nil) ⇒ String

Delete a object record.

Examples:

sf.data.delete_record :Hoge__c, record_id: 'xxxxxxx'
sf.data.delete_record :Hoge__c, where: {Name: 'Jonny B.Good', Country: 'USA'}

Parameters:

  • object_type (Symbol, String)

    Object Type (ex. Account)

  • record_id (String) (defaults to: nil)

    Id of the object

  • where (Hash) (defaults to: nil)

    conditions to identify a record

  • target_org (Symbol, String) (defaults to: nil)

    an alias of paticular org, or username can be used

  • api_version (Numeric) (defaults to: nil)

    override the api version used for api requests made by this command

Returns:

  • (String)

    ID that is deleted.

See Also:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sf_cli/sf/data/delete_record.rb', line 19

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

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