Fetching Search Results with SOAP Requests in NetSuite

NetSuite’s SOAP-based web services allow for advanced searches, including searching for records by their internal IDs. This article will guide you through constructing SOAP requests to fetch search results by internal ID, with examples.

To fetch data, construct a SOAP request specifying the criteria and columns you want to search for. Below is an example of an item search by internal ID.

Example: Item Search Request XML by Internal ID

<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_2019_1.platform.webservices.netsuite.com'
    xmlns:listAcct='urn:accounting_2019_1.lists.webservices.netsuite.com'
    xmlns:platformCommon='urn:common_2019_1.platform.webservices.netsuite.com'
    xmlns:platformMsgs='urn:messages_2019_1.platform.webservices.netsuite.com'>
    <soapenv:Header>
        <tokenPassport xsi:type='platformCore:TokenPassport'>
            <account xsi:type='xsd:string'>Account Number</account>
            <consumerKey xsi:type='xsd:string'>Consumer Key</consumerKey>
            <token xsi:type='xsd:string'>Token</token>
            <nonce xsi:type='xsd:string'>Auto-generated nonce</nonce>
            <timestamp xsi:type='xsd:long'>Auto-generated timestamp</timestamp>
            <signature algorithm='HMAC_SHA256' xsi:type='platformCore:TokenPassportSignature'>Auto-generated Signature using Client Secret</signature>
        </tokenPassport>
    </soapenv:Header>
    <soapenv:Body>
        <search xsi:type='platformMsgs:SearchRequest'>
            <searchRecord xsi:type='listAcct:ItemSearchAdvanced'>
                <criteria xsi:type='listAcct:ItemSearch'>
                    <basic xsi:type='platformCommon:ItemSearchBasic'>
                        <internalId operator='anyOf' xsi:type='platformCore:SearchMultiSelectField'>
                            <searchValue xsi:type='platformCore:RecordRef' internalId='3401'></searchValue>
                            <searchValue xsi:type='platformCore:RecordRef' internalId='23069'></searchValue>
                        </internalId>
                        <inventoryLocation operator='anyOf' xsi:type='platformCore:SearchMultiSelectField'>
                            <searchValue xsi:type='platformCore:RecordRef' internalId='15'>
                                <name xsi:type='xsd:string'>NBD</name>
                            </searchValue>
                        </inventoryLocation>
                        <isInactive xsi:type='platformCore:SearchBooleanField'>
                            <searchValue xsi:type='xsd:boolean'>false</searchValue>
                        </isInactive>
                        <type operator='anyOf' xsi:type='platformCore:SearchEnumMultiSelectField'>
                            <searchValue xsi:type='xsd:string'>_inventoryItem</searchValue>
                        </type>
                    </basic>
                </criteria>
                <columns xsi:type='listAcct:ItemSearchRow'>
                    <basic xsi:type='platformCommon:ItemSearchRowBasic'>
                        <displayName xsi:type='platformCore:SearchColumnStringField'>
                            <customLabel xsi:type='xsd:string'>displayName</customLabel>
                        </displayName>
                        <internalId xsi:type='platformCore:SearchColumnSelectField'>
                            <customLabel xsi:type='xsd:string'>internalId</customLabel>
                        </internalId>
                        <inventoryLocation xsi:type='platformCore:SearchColumnSelectField'>
                            <customLabel xsi:type='xsd:string'>inventoryLocation</customLabel>
                            <searchValue xsi:type='platformCore:RecordRef'>
                                <name xsi:type='xsd:string'/>
                            </searchValue>
                        </inventoryLocation>
                        <itemId xsi:type='platformCore:SearchColumnStringField'>
                            <customLabel xsi:type='xsd:string'>itemId</customLabel>
                        </itemId>
                        <locationQuantityAvailable xsi:type='platformCore:SearchColumnDoubleField'>
                            <customLabel xsi:type='xsd:string'>locationQuantityAvailable</customLabel>
                        </locationQuantityAvailable>
                        <type xsi:type='platformCore:SearchColumnEnumSelectField'>
                            <customLabel xsi:type='xsd:string'>type</customLabel>
                        </type>
                        <customFieldList xsi:type='platformCore:SearchColumnCustomFieldList'>
                            <customField internalId='4605' scriptId='custitem_po_erd_1' xsi:type='platformCore:SearchColumnDateCustomField'>
                                <customLabel xsi:type='xsd:string'>Next PO Expected Date 1</customLabel>
                            </customField>
                        </customFieldList>
                    </basic>
                </columns>
            </searchRecord>
        </search>
    </soapenv:Body>
</soapenv:Envelope>

Ensure your SOAP request includes the correct authentication details (account number, consumer key, token, nonce, timestamp, and signature).

Leave a comment

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