Purchase Order Details Bulk Extraction via SOAP Web Services via search and getList operation

SOAP Web services can be used for extracting purchase details from the NetSuite account. We need to define the SOAP request with the body to fetch the data. With the SOAP request, we can directly fetch the data from the NetSuite. SOAP is a standard NetSuite API.

Following are the steps for the extraction of  Purchase Order details from the NetSuite:

  • PURCHASE_ORDER_SEARCH – extract all purchase order internal ids using the PURCHASE_ORDER_SEARCH SOAP Request. The response result page size is 1000. The operation name is search
  • SEARCH_MORE_PAGE – Send the SEARCH_MORE_PAGE request if the PURCHASE_ORDER_SEARCH response has multiple pages. Search id for the request will be fetched from the initial request(PURCHASE_ORDER_SEARCH  ) response. Multiple calls needed for the request which depend on pagesize. The operation name is searchMoreWithId
  • PURCHASE_ORDER_GETLIST – after getting all the internal ids of the Purchase order, need to send the PURCHASE_ORDER_GETLIST request for extracting all the purchase order details. In the request we can specify up to 200 record ids to fetch the datas . The operation name is getList

The sample body request for the SOAP Request for PURCHASE_ORDER_SEARCH.

<soapenv:Envelope
	xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
	xmlns:urn="urn:messages_2021_2.platform.webservices.netsuite.com"
	xmlns:urn1="urn:core_2021_2.platform.webservices.netsuite.com"
	xmlns:listRel="urn:relationships_2021_2.lists.webservices.netsuite.com"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<soapenv:Header>
		<urn:preferences>
            <urn1:bodyFieldsOnly>false</urn1:bodyFieldsOnly>
            <urn1:pageSize>10</urn1:pageSize>
        </urn:preferences>
		<urn:partnerInfo></urn:partnerInfo>
		<urn:tokenPassport>
			<urn1:account>{{ACCOUNT_ID}}</urn1:account>
			<urn1:consumerKey>{{CONSUMER_KEY}}</urn1:consumerKey>
			<urn1:token>{{TOKEN_ID}}</urn1:token>
			<urn1:nonce>{{nonce}}</urn1:nonce>
			<urn1:timestamp>{{timestamp}}</urn1:timestamp>
			<urn1:signature algorithm="HMAC-SHA256">{{signature}}</urn1:signature>
		</urn:tokenPassport>
	</soapenv:Header>
	<soapenv:Body>
		<search
			xmlns="urn:messages_2021_2.platform.webservices.netsuite.com">
			<searchRecord xsi:type="ns9:TransactionSearchBasic"
				xmlns:ns9="urn:common_2021_2.platform.webservices.netsuite.com">
				<ns9:type operator="anyOf" xsi:type="ns12:SearchEnumMultiSelectField"
					xmlns:ns12="urn:core_2021_2.platform.webservices.netsuite.com">
					<ns12:searchValue xsi:type="xsd:string">_purchaseOrder</ns12:searchValue>
				</ns9:type>
                <ns9:lastModifiedDate operator="within" xsi:type="ns3:SearchDateField"
                    xmlns:ns3="urn:core_2021_2.platform.webservices.netsuite.com">
                     <ns3:searchValue xsi:type="xsd:dateTime">2017-05-21T00:16:17.750Z</ns3:searchValue>
                     <ns3:searchValue2 xsi:type="xsd:dateTime">2022-02-22T00:17:53.015Z</ns3:searchValue2>
                </ns9:lastModifiedDate>
			</searchRecord>
		</search>
	</soapenv:Body>
</soapenv:Envelope>

The sample body request for the SOAP Request for SEARCH_MORE_PAGE.

<soapenv:Envelope
	xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
	xmlns:urn="urn:messages_2021_2.platform.webservices.netsuite.com"
	xmlns:urn1="urn:core_2021_2.platform.webservices.netsuite.com"
	xmlns:listRel="urn:relationships_2021_2.lists.webservices.netsuite.com"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<soapenv:Header>
		<urn:preferences></urn:preferences>
		<urn:partnerInfo></urn:partnerInfo>
		<urn:tokenPassport>
			<urn1:account>{{ACCOUNT_ID}}</urn1:account>
			<urn1:consumerKey>{{CONSUMER_KEY}}</urn1:consumerKey>
			<urn1:token>{{TOKEN_ID}}</urn1:token>
			<urn1:nonce>{{nonce}}</urn1:nonce>
			<urn1:timestamp>{{timestamp}}</urn1:timestamp>
			<urn1:signature algorithm="HMAC-SHA256">{{signature}}</urn1:signature>
		</urn:tokenPassport>
	</soapenv:Header>
	<soapenv:Body>
        <urn:searchMoreWithId>
            <searchId>{searchid}</searchId>
            <pageIndex>2</pageIndex>
        </urn:searchMoreWithId>
	</soapenv:Body>
</soapenv:Envelope>

The Sample request body for the PURCHASE_ORDER_GETLIST

<soapenv:Envelope
	xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
	xmlns:urn="urn:messages_2021_2.platform.webservices.netsuite.com"
	xmlns:urn1="urn:core_2021_2.platform.webservices.netsuite.com"
	xmlns:listRel="urn:relationships_2021_2.lists.webservices.netsuite.com"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<soapenv:Header>
		<urn:preferences></urn:preferences>
		<urn:partnerInfo></urn:partnerInfo>
		<urn:tokenPassport>
			<urn1:account>{{ACCOUNT_ID}}</urn1:account>
			<urn1:consumerKey>{{CONSUMER_KEY}}</urn1:consumerKey>
			<urn1:token>{{TOKEN_ID}}</urn1:token>
			<urn1:nonce>{{nonce}}</urn1:nonce>
			<urn1:timestamp>{{timestamp}}</urn1:timestamp>
			<urn1:signature algorithm="HMAC-SHA256">{{signature}}</urn1:signature>
		</urn:tokenPassport>
	</soapenv:Header>
	<soapenv:Body>
		<urn:getList>
			<urn.baseRef internalId="3254" type="purchaseOrder" xsi:type="platformCore:RecordRef"
				xmlns:platformCore="urn:core_2021_2.platform.webservices.netsuite.com"/>
				<urn.baseRef internalId="5096" type="purchaseOrder" xsi:type="platformCore:RecordRef"
					xmlns:platformCore="urn:core_2021_2.platform.webservices.netsuite.com"/>
				</urn:getList>
			</soapenv:Body>
		</soapenv:Envelope>

Leave a comment

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