ConcourseSuite Support

Support
Corporate
PUBLIC PROFILE

I need to restrict the records sent from the server by setting some filters. How do I do that?

Filters that can be set for a SELECT XML API call should be properties that are defined in the list class (Contact email addresses corresponds to ContactEmailAddressList which extends EmailAddressList). These properties are used in the java source files to restrict the records. Also the name specified in the API call should match the member present in the List class. There is no documentation which describes the filters available in each List class that can be applied. Hence the developer will need to look at the CRM source code to determine the fields. The documentation will be updated in the future to specify what filters are available for a particular class.

Here is an XML API example where a list of contact email addresses are requested from the server, but returned records need to belong to a particular contact.

//Add Meta Info
ArrayList meta = new ArrayList();
meta.add("email");
meta.add("typeName");
meta.add("primaryEmail");
crm.setTransactionMeta(meta);

DataRecord addresses = new DataRecord();
addresses.setName("contactEmailAddressList");
addresses.setAction(DataRecord.SELECT);
addresses.addField("contactId", *** SPECIFY CONTACT ID ***); //filter addresses for a particular contact
crm.load(addresses);

boolean result = crm.commit();
System.out.println("RESPONSE: " + crm.getLastResponse());

Object[] objects = crm.getRecords("com.concursive.crm.web.modules.contacts.dao.ContactEmailAddress").toArray();
ContactEmailAddress[] addresses = new ContactEmailAddress[objects.length];
for (int i = 0; i < objects.length; i++) {
  addresses[i] = (ContactEmailAddress) objects[i];
}

Here is a snapshot of what the com.concursive.crm.web.modules.contacts.dao.EmailAddressList Class looks like

public class EmailAddressList extends Vector {
   ......
  protected int orgId = -1;
  protected int type = -1;
  protected int contactId = -1;
  protected String username = null;
  protected String emailAddress = null;
  //instance info
  protected int instanceId = -1;

   ......

   public void setContactId(int tmp) {
      this.contactId = tmp;
   }

   public void setContactId(String tmp) {
      this.contactId = Integer.parseInt(tmp);
   }

When the API receives the xml packet, it sets the 'contactId' filter and populates the ContactEmailAddressList object, which results in a list of ContactEmailAddress objects whose contactId matches the one specified by the user. The other properties can also be set for filtering the addresses.

Sign in to add your comment.