Detach Soap Operation

The attach and detach operations can be used to define or remove a relationship between two records. For example, a Contact record can be associated with a Partner record or an Opportunity record can be associated with a Customer record.

You can also use the attach/detach operations to attach or detach a file to or from a record. Any file that is in the NetSuite File Cabinet, for example, an MS Word or Excel file or a PDF can be attached to any record other than a custom record.

Note that when attaching Contacts to other entity records, the Contact’s role can also be specified during the request. Contact Roles are roles available in a user-defined list at List > Relationships > Contacts. This list has been exposed as ContactRole in accounting.xsd.

Note that to prevent duplicate records, you should use the alternate upsert and upsertList operations along with external ids to add records to NetSuite.

Request

<soapenv:Envelope
    xmlns:xsd='http://www.w3.org/2001/XMLSchema'
    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
    xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
    xmlns:platformCore='urn:core_2021_2.platform.webservices.netsuite.com'
    xmlns:listRel='urn:relationships_2021_2.lists.webservices.netsuite.com'
    xmlns:listAcct='urn:accounting_2021_2.lists.webservices.netsuite.com'
    xmlns:platformMsgs='urn:messages_2021_2.platform.webservices.netsuite.com'>
    <soapenv:Header>
        <tokenPassport xsi:type='platformCore:TokenPassport'>
            <account xsi:type='xsd:string'>{{accountId}}</account>
            <consumerKey xsi:type='xsd:string'>{{consumerKey}}</consumerKey>
            <token xsi:type='xsd:string'>{{tokenId}}</token>
            <nonce xsi:type='xsd:string'>{{nonce}}</nonce>
            <timestamp xsi:type='xsd:long'>{{timestamp}}</timestamp>
            <signature algorithm='HMAC_SHA256' xsi:type='platformCore:TokenPassportSignature'>{{signature}}</signature>
        </tokenPassport>
    </soapenv:Header>
    <soapenv:Body>
        <detach xsi:type='platformMsgs:DetachRequest'>
            <detachReference xsi:type='platformCore:DetachBasicReference'>
                <detachFrom xsi:type='platformCore:RecordRef' internalId='24' type='customer'></detachFrom>
                <detachedRecord xsi:type='platformCore:RecordRef' internalId='25' type='contact'></detachedRecord>
            </detachReference>
        </detach>
    </soapenv:Body>
</soapenv:Envelope>

Response

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header>
        <platformMsgs:documentInfo
            xmlns:platformMsgs="urn:messages_2021_2.platform.webservices.netsuite.com">
            <platformMsgs:nsId>WEBSERVICES_TSTDRV2782962_073120231425298306597866416_3dd932</platformMsgs:nsId>
        </platformMsgs:documentInfo>
    </soapenv:Header>
    <soapenv:Body>
        <detachResponse
            xmlns="">
            <platformMsgs:writeResponse
                xmlns:platformMsgs="urn:messages_2021_2.platform.webservices.netsuite.com">
                <platformCore:status isSuccess="true"
                    xmlns:platformCore="urn:core_2021_2.platform.webservices.netsuite.com"/>
                    <platformMsgs:baseRef internalId="24" type="customer" xsi:type="platformCore:RecordRef"
                        xmlns:platformCore="urn:core_2021_2.platform.webservices.netsuite.com"/>
                    </platformMsgs:writeResponse>
                </detachResponse>
            </soapenv:Body>
        </soapenv:Envelope>

Leave a comment

Your email address will not be published. Required fields are marked *