RunFilter Method

Sample Code for retrieving the result set of a Filter using the RunFilter method of CampusNexus CRM Utils iService.

In the following sample code we will be retrieving the result set of the Show Alumni Filter which is configured for the Contact Object. The Show Alumni Filter returns the Contacts that are of type Alumni.

Note Note

To use the RunFilter method for retrieving the Filter result set you must create a custom Workspace in Desktop Client and add the required Filter to the custom Workspace Pane. You must get the Filter ID configured in the Pane of the custom Workspace and pass this information to the RunFilter method.

For information on finding the Filter ID configured in a Pane of a custom Workspace, see Querying Main Database.

Sample Code for the RunFilter Method
public void RunFilterSample()
{
    //Creating an Instance of Utils iService
    UtilsWebService utilService = new UtilsWebService();

    //Generating the Username Token Information
    UsernameToken userToken = getUserToken("ParkerRoy", "password");

    //Associating the Username Token Information with the Utils iService Instance
    utilService.RequestSoapContext.Security.Tokens.Add(userToken);
    utilService.RequireMtom = false;

    //Initializing the input parameters
    int filterID = 264534; //ID of the Filter
    long keyColValue=-1;//Initially this parameter is set to -1
    string sortColValue="";//Initially this parameter is set to blank

    //Declaring the output parameters
    string results=null;
    string error="";
    long result = 0;

    //Calling the RunFilter method to retrieve the first page result
    result = utilService.RunFilter(filterID,keyColValue,sortColValue,out  results,out error);
    if (result != 0)
    {
        //Handle Error
    }
    //Current sorting is on the Contact ID Property so passing the value of this Property in the last row of the first result page 
    to fetch values of the next result page.
    keyColValue = 2;//ID of the Contact item displayed in the last row of the first result page
    sortColValue = "2"; //Value of the Contact ID that is displayed in the last row of the first result page

    // 
    result = utilService.RunFilter(filterID, keyColValue, sortColValue, out  results, out error);
    if (result != 0)
    {
        //Handle Error
    }
}

Following XML output is returned for the above code in the first call of the RunFilter method:

<Result count='23' PS='2' OT='3' SC='15' SO='1'>
<H>
<D  PID='15' WD='100' CID='-1'>
<![CDATA[Contact ID]]>
</D>
<D  PID='15' WD='100' CID='-1'>
<![CDATA[Contact ID]]>
</D>
<D  PID='56' WD='130' CID='-1'>
<![CDATA[Name]]>
</D>
<D  PID='57' WD='200' CID='-1'>
<![CDATA[E-mail]]>
</D>
<D  PID='79' WD='116' CID='-1'>
<![CDATA[Phone]]>
</D>
<D  PID='126' WD='125' CID='-1'>
<![CDATA[Created]]>
</D>
<D  PID='13' WD='100' CID='13'>
<![CDATA[No. of Interactions]]>
</D>
</H>
<Data>
<R>
<D>
<![CDATA[1]]>
</D>
<D>
<![CDATA[1]]>
</D>
<D>
<![CDATA[Kay Ross]]>
</D>
<D>
<![CDATA[Kayross@gmail.com]]>
</D>
<D>
<![CDATA[565-434-9752]]>
</D>
<D>
<![CDATA[15-11-2013 03:07]]>
</D>
<D>
<![CDATA[14]]>
</D>
<SCHV>
<![CDATA[1]]>
</SCHV>
</R>
<R>
<D>
<![CDATA[2]]>
</D>
<D>
<![CDATA[2]]>
</D>
<D>
<![CDATA[Brian Mathew]]>
</D>
<D>
<![CDATA[Brianmathew@gmail.com]]>
</D>
<D>
<![CDATA[566-866-3971]]>
</D>
<D>
<![CDATA[15-11-2013 04:26]]>
</D>
<D>
<![CDATA[0]]>
</D>
<SCHV>
<![CDATA[2]]>
</SCHV>
</R>
</Data>
</Result>

The resultset in the above XML code can be interpreted as follows:

  • The Result tag stores two types of tags, the H tag stores the Property names, and the Data tag stores the values of the Properties for each row.

    Additionally, the Result tag displays the following elements:

    • count - Indicates the total number of records in the result set. In this example, there are 23 records.

    • PS - Indicates the value of the Pagesize option. In this example, Pagesize is 2 that is two records will be displayed per page.

    • OT - Indicates the ID of the Object type. In this example, Object type is 3, which is the ID for the Contact Object.

    • SC - Indicates the ID of the sort column in the Table View in CampusNexus CRM. In this example, Contact ID is the sort column with ID as 15.

    • SO - Indicates the Sort order of the items in the sort column. In this example, 1 indicates ascending order.

  • The following table interprets the result set returned in the above XML code.

Property Name

Values in Row 1

Values in Row 2

Contact ID

1

2

Name

Kay Ross

Brian Mathew

E-mail

Kayross@gmail.com

Brianmathew@gmail.com

Phone

565-434-9752

566-866-3971

Created

15-11-2013 03:07

15-11-2013 04:26

No. of Interactions

14

0

Note Note
  • In the Data tag, for each row in the result set, Object ID is displayed twice for Global Objects. For a Team Object, Object ID is followed by a Team ID and then Object ID in the result set for each row.

    The first Object ID is hidden in the Table View and is for internal use and the second Object ID is displayed in the Table View of the Object.

  • The SCHV tag displayed in the Data tag of each row displays the value of the sort column Property for that row in the result set.