Contacts_LoadByCriteria Operation

Applies to QAComplete 14.5, last modified on August 06, 2024

Use the Contacts_LoadByCriteria operation to:

  • Get contacts that match a specific condition. For example, created by a specific user or on a specific day.

  • Get all the contacts in QAComplete projects (if no condition is specified).

The operation can get contacts from one or several projects. To specify a project to get contacts from, use the ProjId value in the AuthenticationData object in the request body. To get contacts from several projects, use the ProjIds value in the AuthenticationData object to specify the list of project IDs.

LoadByCriteria returns results in pages (subsets of data) rather than all at once. Pagination is controlled by the PageSize and PageNumber parameters. For information about working with paginated results, see LoadByCriteria Operations.

You can use the Sorting parameter to sort the contacts before returning them from QAComplete.

To get just one contact, use Contacts_Load.

Requirements

The authenticating user must belong to a user group that has the Read privilege for Contacts.

Parameters

The operation uses the following parameters:

AuthenticationData  :  AuthenticationData, required

An AuthenticationData object with the login information and the ID of the project (or the list of project IDs) that contains the contacts.

Condition  :  string (max 65536 chars)

An XML-formatted string that describes the contacts you want to get. For the syntax and examples, see Condition Syntax.

If you create SOAP requests manually, place the condition string inside CDATA.

To get all contacts, use an empty string or a null value.

Sorting  :  string (max 512 chars)

The order to sort the results before returning them from the web service. For example, by contact ID or last updated date. The format is:

Property1 [ASC | DESC ][, Property2 [ASC | DESC ]] [, ...]]]

where property names are those of the Contact object. If you omit ASC or DESC after a property name, contacts are sorted in ascending order.

Example values:

ContactId
AssignedToName, ContactId
DateUpdated DESC

To keep the default sort order, use an empty string or a null value.

PageSize  :  integer, required

Limits the number of contacts to return in one page. Possible values: 1..200.

The last page may have less items than PageSize. This means the end of the result set.

PageNumber  :  integer, required

A number starting from 1 that specifies the data page to return in the response. To get all pages, send several requests with increasing PageNumber values. For example, if PageSize is 100, PageNumber of 1 will return contacts 1..100, PageNumber of 2 - contacts 101..200 and so on.

If PageNumber exceeds the range, an empty array is returned. If PageNumber is the last page, this page may have less items than PageSize.

Result

An array of Contact objects that contain the contact information.

Example

Sample Code

The example below loads all contacts with the call back date earlier than a specific date.

C#

string login = "[email protected]";
string password = "p@ssword";
int projID = 10372;

// Specifying a condition
string Condition =
@"<Conditions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
              xmlns:xsd='http://www.w3.org/2001/XMLSchema'
              Operation='opLT'>
  <Items Type='tField'>
    <Value xsi:type='xsd:string'>DateCallBack</Value>
  </Items>
  <Items Type='tDate'>
    <Value xsi:type='xsd:string'>2014-09-01T00:00:00</Value>
  </Items>
</Conditions>";
// Specifying the desired sorting
string Sorting = "";
int pageSize = 200;
ServiceSoapClient service = new ServiceSoapClient();

// Preparing AuthenticationData
LoginInfo loginInfo = service.GetLoginInfo("", login, password);
AuthenticationData authData = new AuthenticationData();
authData.AppCode = loginInfo.AppCode;
authData.UserId = loginInfo.UserId;
authData.PassCode = password;
authData.DeptId = loginInfo.DeptId;
authData.ProjId = projID;

// Getting an array of contacts
Contact[] contacts = new Contact[0];
int pageNumber = 1;

do
{
  contacts = service.Contacts_LoadByCriteria(authData, Condition, Sorting, pageSize, pageNumber);
  foreach (Contact contact in contacts)
  {

    Console.WriteLine("{0} from {1}: {2})", contact.ContactPerson, contact.CompanyName, contact.Email);
  }
  pageNumber++;
} while (contacts.Length == pageSize);

Java

String login = "[email protected]";
String password = "p@ssword";
int projID = 10372;

// Specifying a condition
String Condition =
        "<Conditions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\n" +
        "            xmlns:xsd='http://www.w3.org/2001/XMLSchema'\n" +
        "            Operation='opLT'>\n" +
        "  <Items Type='tField'> \n" +
        "    <Value xsi:type='xsd:string'>DateCallBack</Value> \n" +
        "  </Items> \n" +
        "  <Items Type='tDate'> \n" +
        "    <Value xsi:type='xsd:string'>2014-09-01T00:00:00</Value> \n" +
        "  </Items> \n" +
        "</Conditions>";

// Specifying the desired sorting
String Sorting = "";
int pageSize = 10;

ServiceSoap service = new Service().getServiceSoap12();

// Preparing AuthenticationData
LoginInfo loginInfo = service.getLoginInfo("", login, password);
AuthenticationData authData = new AuthenticationData();
authData.setAppCode(loginInfo.getAppCode());
authData.setUserId(loginInfo.getUserId());
authData.setPassCode(password);
authData.setDeptId(loginInfo.getDeptId());
authData.setProjId(projID);

// Getting an array of contacts
List<Contact> contacts;
int pageNumber = 1;

do
{
  contacts = service.contactsLoadByCriteria(authData, Condition, Sorting, pageSize, pageNumber).getContact();
  for (Contact contact : contacts)
  {

    System.out.format("%s from %s: %s", contact.getContactPerson(), contact.getCompanyName(), contact.getEmail());
  }
  pageNumber++;
} while (contacts.size() == pageSize);

Sample Request XML

POST /psws/psws.asmx HTTP/1.1
Host: myteam.mysite.com
Content-Type: text/xml; charset=utf-8
Content-Length: 1044 {Insert an appropriate value here}
SOAPAction: "http://www.pragmaticsw.com/Contacts_LoadByCriteria"
 

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Contacts_LoadByCriteria xmlns="http://www.pragmaticsw.com/">
      <AuthenticationData>
        <AppCode>agSP</AppCode>
        <DeptId>7154</DeptId>
        <ProjId>1032</ProjId>
        <UserId>25315</UserId>
        <PassCode>p@ssword</PassCode>
      </AuthenticationData>
      <Condition>
        <![CDATA[<Conditions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
                             xmlns:xsd='http://www.w3.org/2001/XMLSchema'
                             Operation='opLT'>
          <Items Type='tField'>
            <Value xsi:type='xsd:string'>DateCallBack</Value>
          </Items>
          <Items Type='tDate'>
            <Value xsi:type='xsd:string'>2014-09-01T00:00:00</Value>
          </Items>
        </Conditions>]]>
      
</Condition>
      <Sorting>Title</Sorting>
      <PageSize>200</PageSize>
      <PageNumber>1</PageNumber>
    </Contacts_LoadByCriteria>
  </soap:Body>
</soap:Envelope>

SOAP 1.2

POST /psws/psws.asmx HTTP/1.1
Host: myteam.mysite.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 1052 {Insert an appropriate value here}
 

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <Contacts_LoadByCriteria xmlns="http://www.pragmaticsw.com/">
      <AuthenticationData>
        <AppCode>agSP</AppCode>
        <DeptId>7154</DeptId>
        <ProjId>1032</ProjId>
        <UserId>25315</UserId>
        <PassCode>p@ssword</PassCode>
      </AuthenticationData>
      <Condition>
        <![CDATA[<Conditions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
                             xmlns:xsd='http://www.w3.org/2001/XMLSchema'
                             Operation='opLT'>
          <Items Type='tField'>
            <Value xsi:type='xsd:string'>DateCallBack</Value>
          </Items>
          <Items Type='tDate'>
            <Value xsi:type='xsd:string'>2014-09-01T00:00:00</Value>
          </Items>
        </Conditions>]]>
      
</Condition>
      <Sorting>Title</Sorting>
      <PageSize>200</PageSize>
      <PageNumber>1</PageNumber>
    </Contacts_LoadByCriteria>
  </soap12:Body>
</soap12:Envelope>

Sample Response XML

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: 1947 {The server returns an appropriate value here}
 

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Contacts_LoadByCriteriaResponse xmlns="http://www.pragmaticsw.com/">
      <Contacts_LoadByCriteriaResult>
        <Contact>
          <ContactId>7</ContactId>
          <ContactPerson>John Smith</ContactPerson>
          <CompanyName>Smith & Doe Inc.</CompanyName>
          <Email>[email protected]</Email>
          <Title>Developer</Title>
          <Status>Active</Status>
          <ContactType>Vendor</ContactType>
          <Date1stContact>2012-02-20T00:00:00</Date1stContact>
          <DateCallBack>2014-07-29T00:00:00</DateCallBack>
          <AssigneeUserId>27942</AssigneeUserId>
          <OwnerUserId>27534</OwnerUserId>
          <FolderId>52359</FolderId>
          <AssignedToName>Fry, Alex</AssignedToName>
          <DateCreated>2014-05-30T14:28:18.028</DateCreated>
          <DateUpdated>2014-07-28T05:54:22</DateUpdated>
          <ImportId>0</ImportId>
          <NbrEvents>0</NbrEvents>
          <NbrFiles>0</NbrFiles>
          <NbrNotes>1</NbrNotes>
          <OwnerName>Davis, Eugeny</OwnerName>
          <UpdateUserId>27534</UpdateUserId>
          <UserName>Fry, Alex</UserName>
        </Contact>
        <Contact>
          <ContactId>6</ContactId>
          <ContactPerson>Paul Taylor</ContactPerson>
          <CompanyName>Example Corp.</CompanyName>
          <Email>[email protected]</Email>
          <Title>R&D Group Leader</Title>
          <Status>Active</Status>
          <ContactType>Client</ContactType>
          <Date1stContact>2014-05-24T00:00:00</Date1stContact>
          <DateCallBack>2014-07-28T00:00:00</DateCallBack>
          <AssigneeUserId>27942</AssigneeUserId>
          <OwnerUserId>27572</OwnerUserId>
          <FolderId>52364</FolderId>
          <AssignedToName>Doe, John</AssignedToName>
          <DateCreated>2014-06-13T11:42:44.054</DateCreated>
          <DateUpdated>2014-06-26T03:12:48</DateUpdated>
          <ImportId>0</ImportId>
          <NbrEvents>0</NbrEvents>
          <NbrFiles>0</NbrFiles>
          <NbrNotes>0</NbrNotes>
          <OwnerName>Davis, Eugeny</OwnerName>
          <UpdateUserId>27942</UpdateUserId>
          <UserName>Fry, Alex</UserName>
        </Contact>
      </Contacts_LoadByCriteriaResult>
    </Contacts_LoadByCriteriaResponse>
  </soap:Body>
</soap:Envelope>

SOAP 1.2

HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 1957 {The server returns an appropriate value here}
 

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <Contacts_LoadByCriteriaResponse xmlns="http://www.pragmaticsw.com/">
      <Contacts_LoadByCriteriaResult>
        <Contact>
          <ContactId>7</ContactId>
          <ContactPerson>John Smith</ContactPerson>
          <CompanyName>Smith & Doe Inc.</CompanyName>
          <Email>[email protected]</Email>
          <Title>Developer</Title>
          <Status>Active</Status>
          <ContactType>Vendor</ContactType>
          <Date1stContact>2012-02-20T00:00:00</Date1stContact>
          <DateCallBack>2014-07-29T00:00:00</DateCallBack>
          <AssigneeUserId>27942</AssigneeUserId>
          <OwnerUserId>27534</OwnerUserId>
          <FolderId>52359</FolderId>
          <AssignedToName>Fry, Alex</AssignedToName>
          <DateCreated>2014-05-30T14:28:18.028</DateCreated>
          <DateUpdated>2014-07-28T05:54:22</DateUpdated>
          <ImportId>0</ImportId>
          <NbrEvents>0</NbrEvents>
          <NbrFiles>0</NbrFiles>
          <NbrNotes>1</NbrNotes>
          <OwnerName>Davis, Eugeny</OwnerName>
          <UpdateUserId>27534</UpdateUserId>
          <UserName>Fry, Alex</UserName>
        </Contact>
        <Contact>
          <ContactId>6</ContactId>
          <ContactPerson>Paul Taylor</ContactPerson>
          <CompanyName>Example Corp.</CompanyName>
          <Email>[email protected]</Email>
          <Title>R&D Group Leader</Title>
          <Status>Active</Status>
          <ContactType>Client</ContactType>
          <Date1stContact>2014-05-24T00:00:00</Date1stContact>
          <DateCallBack>2014-07-28T00:00:00</DateCallBack>
          <AssigneeUserId>27942</AssigneeUserId>
          <OwnerUserId>27572</OwnerUserId>
          <FolderId>52364</FolderId>
          <AssignedToName>Doe, John</AssignedToName>
          <DateCreated>2014-06-13T11:42:44.054</DateCreated>
          <DateUpdated>2014-06-26T03:12:48</DateUpdated>
          <ImportId>0</ImportId>
          <NbrEvents>0</NbrEvents>
          <NbrFiles>0</NbrFiles>
          <NbrNotes>0</NbrNotes>
          <OwnerName>Davis, Eugeny</OwnerName>
          <UpdateUserId>27942</UpdateUserId>
          <UserName>Fry, Alex</UserName>
        </Contact>
      </Contacts_LoadByCriteriaResult>
    </Contacts_LoadByCriteriaResponse>
  </soap12:Body>
</soap12:Envelope>

See Also

Contacts_Add
Contacts_Delete
Contacts_Load
Contacts_Update
Contacts Operations
SOAP API Reference

Highlight search results