Monday, October 3, 2016

Search with WSO2 NetSuite Connector - Basic Search

This is the first post in the series, 'Search operation with WSO2 NetSuite Connector'. The search operation in SuiteTalk is used to execute a search on a specific record type based on a set of criteria. The search operation can be used to perform the following types of searches.
  • Basic search
  • Joined search
  • Advanced search 
In this post, I am discussing how we can use search method in WSO2 NetSuite connector to perform the basic search in NetSuite.

Basic search

A basic search lets you to search records of a specific type using the fields on that record as search filters.

To perform a basic search in which you specify search filter criteria only, use:
  •  < Record > Search
  •  < Record > SearchBasic
In SuiteTalk, any record that supports search operation has a corresponding < Record > Search object, which contains a basic element. The basic element references a < Record > SearchBasic object, which defines all available search criteria (filter fields) specific to that record type.

You can find the search types which are used throughout web services to populate the system defined lists in the schema browser.

The enumerations (the available values that should be used to populate these fields in your web services requests. ) are defined in the platformCoreTyp XSD.

SuiteTalk provides a collection of operators, and they differ depending on the field type you are searching. For example, the following are the collection of operators supported by the SearchStringFieldOperator.
  • contains
  • doesNotContain
  • doesNotStartWith
  • empty
  • hasKeywords
  • is
  • isNot
  • notEmpty
  • startsWith
Let see how to perform basic customer search via WSO2 NetSuite Connector.

Create Proxy service to search customer with given email Id from NetSuite and invoke the proxy with the following request.

Proxy Service 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="netsuiteSearch"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="http,https">
   <target>
      <inSequence>
         <property xmlns:ns="wso2.connector.netsuite"
                   expression="//ns:apiUrl/text()"
                   name="apiUrl"/>
         <property xmlns:ns="wso2.connector.netsuite"
                   expression="//ns:applicationId/text()"
                   name="applicationId"/>
         <property xmlns:ns="wso2.connector.netsuite"
                   expression="//ns:email/text()"
                   name="email"/>
         <property xmlns:ns="wso2.connector.netsuite"
                   expression="//ns:password/text()"
                   name="password"/>
         <property xmlns:ns="wso2.connector.netsuite"
                   expression="//ns:account/text()"
                   name="account"/>
         <property xmlns:ns="wso2.connector.netsuite"
                   expression="//ns:bodyFieldsOnly/text()"
                   name="bodyFieldsOnly"/>
         <property xmlns:ns="wso2.connector.netsuite"
                   expression="//ns:returnSearchColumns/text()"
                   name="returnSearchColumns"/>
         <property xmlns:ns="wso2.connector.netsuite"
                   expression="//ns:pageSize/text()"
                   name="pageSize"/>
         <property xmlns:ns="wso2.connector.netsuite"
                   expression="//ns:searchRecord/*"
                   name="searchRecord"/>
         <netsuite.init>
            <apiUrl>{$ctx:apiUrl}</apiUrl>
            <applicationId>{$ctx:applicationId}</applicationId>
            <password>{$ctx:password}</password>
            <email>{$ctx:email}</email>
            <account>{$ctx:account}</account>
         </netsuite.init>
         <netsuite.search>
            <bodyFieldsOnly>{$ctx:bodyFieldsOnly}</bodyFieldsOnly>
            <returnSearchColumns>{$ctx:returnSearchColumns}</returnSearchColumns>
            <pageSize>{$ctx:pageSize}</pageSize>
            <searchRecord>{$ctx:searchRecord}</searchRecord>
         </netsuite.search>
         <respond/>
      </inSequence>
      <outSequence>
         <log/>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>

Request

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="wso2.connector.netsuite">
   <soapenv:Header />
   <soapenv:Body>
      <urn:apiUrl>https://webservices.na1.netsuite.com/services/NetSuitePort_2015_2</urn:apiUrl>
      <urn:applicationId>32XXX75-CXXE-47X7-BX7-A3EXXXX9D</urn:applicationId>
      <urn:email>johndoe@abc.com</urn:email>
      <urn:password>john4doe</urn:password>
      <urn:account>TSTXXXXXX12</urn:account>
      <urn:searchRecord>
         <platformMsgs:searchRecord xmlns:platformMsgs="urn:messages_2015_2.platform.webservices.netsuite.com" xmlns:ns1="urn:relationships_2015_2.lists.webservices.netsuite.com" xmlns:platformCore="urn:core_2015_2.platform.webservices.netsuite.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:CustomerSearch">
            <basic>
               <email operator="is" xsi:type="platformCore:SearchStringField">
                  <searchValue>dave@cleanenergy.com</searchValue>
               </email>
            </basic>
         </platformMsgs:searchRecord>
      </urn:searchRecord>
   </soapenv:Body>
</soapenv:Envelope>

No comments:

Post a Comment