Problem Statement:
It is possible to create a saved search with SOAP Web Services.
Solution
We can run an existing saved search with additional filters by simply adding a few more lines in the SOAP HTTP Request. Find the sample request and response below where the search operation’s TransactionSearchAdvanced to load an existing transaction saved search and within the XML, adds the filter to only include the main line in the results.
Request Payload
SPOILER WARNING
<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_1.platform.webservices.netsuite.com’
xmlns:tranSales=’urn:sales_2021_1.transactions.webservices.netsuite.com’
xmlns:platformCommon=’urn:common_2021_1.platform.webservices.netsuite.com’
xmlns:platformMsgs=’urn:messages_2021_1.platform.webservices.netsuite.com’>
<soapenv:Header>
<tokenPassport xsi:type=’platformCore:TokenPassport’>
<account xsi:type=’xsd:string’>TSTDRV2549029</account>
<consumerKey xsi:type=’xsd:string’>*****</consumerKey>
<token xsi:type=’xsd:string’>*****</token>
<nonce xsi:type=’xsd:string’>*****</nonce>
<timestamp xsi:type=’xsd:long’>*****</timestamp>
<signature algorithm=’HMAC_SHA256′ xsi:type=’platformCore:TokenPassportSignature’>*****</signature>
</tokenPassport>
</soapenv:Header>
<soapenv:Body>
<search xsi:type=’platformMsgs:SearchRequest’>
<searchRecord xsi:type=’tranSales:TransactionSearchAdvanced’ savedSearchScriptId=’customsearch_salesord_test’>
<criteria xsi:type=’tranSales:TransactionSearch’>
<basic xsi:type=’platformCommon:TransactionSearchBasic’>
<mainLine xsi:type=’platformCore:SearchBooleanField’>
<searchValue xsi:type=’xsd:boolean’>true</searchValue>
</mainLine>
</basic>
</criteria>
</searchRecord>
</search>
</soapenv:Body>
</soapenv:Envelope>
Response Payload
SPOILER WARNING
<?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_1.platform.webservices.netsuite.com”>
<platformMsgs:nsId>*****</platformMsgs:nsId>
</platformMsgs:documentInfo>
</soapenv:Header>
<soapenv:Body>
<searchResponse
xmlns=””>
<platformCore:searchResult
xmlns:platformCore=”urn:core_2021_1.platform.webservices.netsuite.com”>
<platformCore:status isSuccess=”true”/>
<platformCore:totalRecords>1</platformCore:totalRecords>
<platformCore:pageSize>1000</platformCore:pageSize>
<platformCore:totalPages>1</platformCore:totalPages>
<platformCore:pageIndex>1</platformCore:pageIndex>
<platformCore:searchId>WEBSERVICES_TSTDRV2549029_091320229374855081156540889_b794f2</platformCore:searchId>
<platformCore:searchRowList>
<platformCore:searchRow xsi:type=”tranSales:TransactionSearchRow”
xmlns:tranSales=”urn:sales_2021_1.transactions.webservices.netsuite.com”>
<tranSales:basic
xmlns:platformCommon=”urn:common_2021_1.platform.webservices.netsuite.com”>
<platformCommon:account>
<platformCore:searchValue internalId=”130″/>
</platformCommon:account>
<platformCommon:amount>
<platformCore:searchValue>1629.95</platformCore:searchValue>
</platformCommon:amount>
<platformCommon:entity>
<platformCore:searchValue internalId=”467″/>
</platformCommon:entity>
<platformCommon:mainLine>
<platformCore:searchValue>true</platformCore:searchValue>
</platformCommon:mainLine>
<platformCommon:mainName>
<platformCore:searchValue>467</platformCore:searchValue>
</platformCommon:mainName>
<platformCommon:tranDate>
<platformCore:searchValue>2022-08-23T17:00:00.000-07:00</platformCore:searchValue>
</platformCommon:tranDate>
<platformCommon:tranId>
<platformCore:searchValue>106</platformCore:searchValue>
</platformCommon:tranId>
<platformCommon:type>
<platformCore:searchValue>_salesOrder</platformCore:searchValue>
</platformCommon:type>
</tranSales:basic>
</platformCore:searchRow>
</platformCore:searchRowList>
</platformCore:searchResult>
</searchResponse>
</soapenv:Body>
</soapenv:Envelope>