Sunday, September 16, 2018

Web Service > PHPToolkit > Entity Record> Delete Code Sample

As per the Suite Talk Web Services Platform Guide, the delete operation is used to delete an existing instance of a record in NetSuite. This example will guide developer how to perform a delete operation thru web service using PHPToolkit.


Note: This article requires existing knowledge of Web Services and PHP.

Note: The information contained in this article may or may not lead to the alteration of data in your production account, thus NetSuite holds no liability whether you choose to follow the instructions. In the event that data is deleted, altered or removed and requires restoration there will be applicable fees. Please proceed with caution.


Code snippet that deletes a contact record:




require_once 'PHPtoolkit.php';

require_once 'login_info.php';

global $myNSclient;


# ===============

//when invoking a delete method it requires a baseRef parameter

$contactDelete = new nsRecordRef(array('type' => 'contact',

'internalId' => '1'));

//assign the result to a writeResponse to extract the result

$writeResponse = $myNSclient->delete($contactDelete);





echo "Success deleted a contact record.";




//display the reason why the request fail

echo $writeResponse->statusDetail[0]->message;



catch (Exception $e)


echo "Unable to delete the contact due to the following error: " . $e;






The above code generates the following SOAP request:


SOAP Request:

    <Header />
            <baseRef type="RecordRef" type="contact" internalId="1"/>

SOAP Response:

                <status isSuccess="true" />
                <baseRef type="RecordRef" type="contact" internalId="179" />

No comments:

Post a Comment