Sunday, November 4, 2018

Advanced Contact Search with Customer or Vendor details using Java

After retrieving a Contact record using the Get Operation you can get the Company internal id, which refers to the entity that the Contact record is attached to.

However, Contact records are not attached to Customers only, they can be attached to Vendor records as well.

Given the above scenario, the RecordRef from the Contact's Company field only has the internal id, but not the Record Type.

To determine if the Contact record is attached to a Customer record or a Vendor record one can use the Advanced Contact Search and add Customer and Vendor join columns.

The following is a sample SOAP request for an Advanced Contact Search that will have results under the Customer join if the Contact is attached to a Customer, will have results under the Vendor join if the Contact is attached to a Vendor and both if it is attached to a Customer record that is also a Vendor:

The following is a Java code snippet to produce the above SOAP request:

  ContactSearchAdvanced contactSearchAdvanced = new ContactSearchAdvanced();

  ContactSearchRow columns = new ContactSearchRow();
  CustomerSearchRowBasic customerJoin = new CustomerSearchRowBasic();
  VendorSearchRowBasic vendorJoin = new VendorSearchRowBasic();
  ContactSearchRowBasic basic = new ContactSearchRowBasic();





  ContactSearch criteria = new ContactSearch();

  ContactSearchBasic searchBasic = new ContactSearchBasic();
  SearchMultiSelectField internalId = new SearchMultiSelectField();
  RecordRef[] searchValues = new RecordRef[1];
  searchValues[0] = new RecordRef();
  searchValues[0].setInternalId("14"); // Set a Contact internal id



  SearchResult result =;

The above code will also use the following methods:

 public static SearchColumnStringField[] newSearchColumnStringFieldArray() {
  SearchColumnStringField[] searchColumnStringField = new SearchColumnStringField[1];
  searchColumnStringField[0] = new SearchColumnStringField();
  return searchColumnStringField;

 public static SearchColumnSelectField[] newSearchColumnSelectFieldArray() {
  SearchColumnSelectField[] searchColumnSelectField = new SearchColumnSelectField[1];
  searchColumnSelectField[0] = new SearchColumnSelectField();
  return searchColumnSelectField;

No comments:

Post a Comment