-1

I have to delete a single record based on id but I got

error bad id 2 Array ( [0] => stdClass Object ( [errors] => Array ( [0] => stdClass Object ( [message] => bad id 2 [statusCode] => MALFORMED_ID ) ) [id] => [success] => ) )

<?php
    require_once('userAuth.php');

    require_once ('soapclient/SforcePartnerClient.php');

    $mySforceConnection = new SforcePartnerClient();
    $mySforceConnection->createConnection("PartnerWSDL.xml");
    $mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);
    $ids=array();
    $id=$_GET['id'];
    array_push($ids, $id);
    print_r($deleteResult);
    $deleteResult = $mySforceConnection->delete($ids);
?>
  • Well, what was the Id value you passed the API? Was it in fact a Malformed ID? – David Reed Nov 13 '18 at 13:21
  • It was id 2 that i am getting through localhost/SFDC/delete.php?id=2 – vineet shirdhonkar Nov 13 '18 at 13:24
  • 1
    '2' is not a valid Salesforce 15 or 18-character Id. Are you trying to use an External Id field? Would you please edit your question to provide more context? – David Reed Nov 13 '18 at 13:25
  • yes i am using external id which is auto number field – vineet shirdhonkar Nov 13 '18 at 13:26
1

The delete() SOAP API call does not accept external Ids. It requires valid Salesforce Ids.

To delete a record based on its External Id, you need to first perform a query() to locate the Id(s) for the record(s) with that External Id value, then pass those Ids to delete().

  • can you provide sample code to delete external id of salesforce record in php ? – vineet shirdhonkar Nov 13 '18 at 13:38
  • 1
    No. I'm not a PHP programmer. – David Reed Nov 13 '18 at 13:44
  • can you provide some hint how to to do this because i don't want to pass external ids i want to delete only one record at a time based on single external id – vineet shirdhonkar Nov 14 '18 at 4:00
  • Resolved the issue by giving salesforce id – vineet shirdhonkar Nov 14 '18 at 5:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.