Using CustomSearchJoin and CustomSearchRowBasic Example

If you are using the 2013.2 WSDL or later, you have access to CustomSearchJoin and CustomSearchRowBasic. This topic shows how you might use these objects in your code. For details on the general purpose of these objects and sample use cases, see Overview of CustomSearchJoin and CustomSearchRowBasic.

The example below assumes that your employee record has been altered to include a custom field that references the account record. This sample shows how you might use EmployeeSearchAdvanced to find employee records associated with an account of a certain type and value.

          public  void testSearch1() throws Exception{


// We are searching for employees associated with a certain type of account. Here we specify that account.

AccountSearchBasic accountSearchBasic = new AccountSearchBasic();
accountSearchBasic.setType(new SearchEnumMultiSelectField(new String[]{AccountType.__bank}, SearchEnumMultiSelectFieldOperator.anyOf));


// Here we specify the field on the employee record that references the account record.

CustomizationRef field_account = new CustomizationRef();
field_account.setScriptId("custentity_account");


// Here we create a custom search join object.
CustomSearchJoin customSearchJoin = CustomSearchJoin(field_account, accountSearchBasic);


// Next, we pass the custom search join that we just created into an EmployeeSearch instance.

EmployeeSearch employeeSearch = new EmployeeSearch();
employeeSearch.setCustomSearchJoin(new CustomSearchJoin[] {customSearchJoin});


// Next, we specify that we want the results to include the balance of the account.

AccountSearchRowBasic accountSearchRowBasic = new AccountSearchRowBasic();
accountSearchRowBasic.setBalance(new SearchColumnDoubleField[]{new SearchColumnDoubleField()});
CustomSearchRowBasic customSearchRowBasic =new CustomSearchRowBasic(field_account,accountSearchRowBasic);


// Here, we specify that we want the employee's internal ID included in the results.

EmployeeSearchRowBasic employeeSearchRowBasic = new EmployeeSearchRowBasic();
employeeSearchRowBasic.setInternalId(new SearchColumnSelectField[]{new SearchColumnSelectField()});


// In the following snippet, we pass the specified search columns into an EmployeeSearchRow instance.

EmployeeSearchRow employeeSearchRow = new EmployeeSearchRow();
employeeSearchRow.setCustomSearchJoin(new CustomSearchRowBasic[]{customSearchRowBasic});
employeeSearchRow.setBasic(employeeSearchRowBasic);


// Create the advanced search.

EmployeeSearchAdvanced employeeSearchAdvanced = new EmployeeSearchAdvanced();
employeeSearchAdvanced.setCriteria(employeeSearch);
employeeSearchAdvanced.setColumns(employeeSearchRow);

c.search(employeeSearchAdvanced);

} 

        
Note:

CustomSearchJoin and CustomSearchRowBasic are available only for accounts that have upgraded to the 2013.2 or a later endpoint.

Related Topics

Joining Through Custom Fields
CustomSearch Objects Defined
CustomSearchJoin Usage Notes
search
Basic Searches in SOAP Web Services
Advanced Searches in SOAP Web Services
Search-Related Sample Code

General Notices