Searching by lastModifiedDate

This sample shows how to create a customer, and then search for the customer that was created based on a specific time frame. In this case, the sample uses the lastModifiedDate field to search “within” a couple of seconds before the customer was created and then a minute after. The search returns the record that was previously created.

Java

          Customer c = (Customer) new TestCustomer().createMinimalRecord();
Calendar timeFrom = Calendar.getInstance();
WriteResponse wr = sessMgr.getPort().add(c);
outputResult(wr.getStatus().isIsSuccess());
 
Calendar timeTo = Calendar.getInstance();
timeTo.setTimeInMillis(timeTo.getTimeInMillis() + 60000);
 
CustomerSearch cs = new CustomerSearch();
CustomerSearchBasic csb = new CustomerSearchBasic();
SearchDateField sdf = new SearchDateField();
sdf.setOperator(SearchDateFieldOperator.within);
sdf.setSearchValue(timeFrom);
sdf.setSearchValue2(timeTo);
csb.setLastModifiedDate(sdf);
 
cs.setBasic(csb);
 
SearchResult sr = sessMgr.getWrappedPort().search(cs, this); 

        

SOAP

          <searchRecord xsi:type="ns1:CustomerSearch" 
   xmlns:ns1="urn:relationships_2017_1.lists.webservices.netsuite.com">
               <ns1:basic xsi:type="ns2:CustomerSearchBasic"
   xmlns:ns2="urn:common_2017_1.platform.webservices.netsuite.com">
                  <ns2:lastModifiedDate operator="within" xsi:type="ns3:SearchDateField"
   xmlns:ns3="urn:core_2017_1.platform.webservices.netsuite.com">
                     <ns3:searchValue xsi:type="xsd:dateTime">2007-02-10T00:16:17.750Z</ns3:searchValue>
                     <ns3:searchValue2 xsi:type="xsd:dateTime">2007-02-10T00:17:53.015Z</ns3:searchValue2>
                  </ns2:lastModifiedDate>
               </ns1:basic>
            </searchRecord> 

        

Related Topics

General Notices