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();
basic.setAddress(newSearchColumnStringFieldArray());
basic.setCompany(newSearchColumnSelectFieldArray());
basic.setEmail(newSearchColumnStringFieldArray());
basic.setEntityId(newSearchColumnStringFieldArray());
customerJoin.setEntityId(newSearchColumnStringFieldArray());
customerJoin.setInternalId(newSearchColumnSelectFieldArray());
vendorJoin.setEntityId(newSearchColumnStringFieldArray());
vendorJoin.setInternalId(newSearchColumnSelectFieldArray());
columns.setCustomerJoin(customerJoin);
columns.setVendorJoin(vendorJoin);
columns.setBasic(basic);
ContactSearch criteria = new ContactSearch();
ContactSearchBasic searchBasic = new ContactSearchBasic();
SearchMultiSelectField internalId = new SearchMultiSelectField();
internalId.setOperator(SearchMultiSelectFieldOperator.anyOf);
RecordRef[] searchValues = new RecordRef[1];
searchValues[0] = new RecordRef();
searchValues[0].setInternalId("14"); // Set a Contact internal id
internalId.setSearchValue(searchValues);
searchBasic.setInternalId(internalId);
criteria.setBasic(searchBasic);
contactSearchAdvanced.setColumns(columns);
contactSearchAdvanced.setCriteria(criteria);
System.out.println("Searching...");
SearchResult result = port.search(contactSearchAdvanced);
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