Using the PaginationSearch Web Method
4 min
this web method retrieves one or more business objects based on the search criteria this is a microsoft sql style query compared to the other search web methods, you can use this general purpose web method to express arbitrarily complex queries request syntax frsheatintegrationsearchresponse paginationsearch(string sessionkey, string tenantid, objectquerydefinition query, int skip) parameters sessionkey the session key from the connect web method tenantid the tenant for which the session key is authenticated query a structure describing the search criteria it follows the structure of a microsoft sql select request and captures most of the possible parameters in select queries, including top , where , join , and order by clauses in paginationsearch method, the top value is considered as the page size parameter if top is not specified, then this method returns 100 records by default skip integer value which indicates the number of records that need to be skipped from top of the result set (that is, similar to offset parameter) return value frsheatintegrationsearchresponse object, defined as follows public class frsheatintegrationsearchresponse { public string status { get; set; } public string exceptionreason { get; set; } public list\<list\<webservicebusinessobject>> objlist { get; set; } } the frsheatintegrationsearchresponse class has the following fields status provides a status value indicating whether the operation was successful a full description of the available status values is provided in the table below exceptionreason contains exception information, if the system throws an exception when running the connect web method objlist contains a list of the results found, if the value of the status field is success the outer list contains multiple business objects, if the search condition matched more than one business object the inner list contains joined business objects, if the search condition requested joins unlike microsoft sql response, fields from each joined objects are kept in a separate list they are not mingled together if you do not specify the top value in the request, then objlist will return top 100 records from the result list by default the below table lists the available status values and describes how to interpret them \<font color="#ffffff">status\</font>\<font color="#ffffff">description\</font> success successfully found the business objects access the business object list from the objlist field, which returns the results as a list of webservicebusinessobjects error objecttablemap field \<fieldname> is not found in table \<business object># cannot find the business objects the objlist field is null inspect the corresponding exceptionreason field to determine why the web method failed following are the common error examples a typical error is table not found , which occurs when the specified business object does not exist in the tenant ensure that the name of the business object is spelled properly another common error is that the specified field does not exist for the business object the error message is ensure that the field name is spelled correctly and defined for the specified business object notfound the specified business object exists in the tenant, but the specified recid does not match any of the existing records in the object since this is not an exceptional condition, no exception is stored in the exceptionreason field but the objlist field is null ensure that the recid for the intended record exists in the tenant example 1 the following example searches for incident records where the priority is 1 and the status is active , and retrieves the corresponding incident numbers from the matching results by skipping the first 10 records objectquerydefinition query = new objectquerydefinition(); query select = new selectclass(); // retrieve just the incidentnumber field value from the incident, // when invoking the search fieldclass\[] incidentfieldobjects = new fieldclass\[] { new fieldclass() { name = "incidentnumber", type = "text" } }; query select fields = incidentfieldobjects; query from = new fromclass(); query from object = "incident"; query where = new ruleclass\[] { new ruleclass() { join = "and", condition = "=", field = "priority", value = "1" }, new ruleclass() { join = "and", condition = "=", field = "status", value = "active" } }; int skip =10; frsheatintegrationsearchresponse searchresponse = frsvc paginationsearch(authsessionkey, tenantid, query, skip); if (searchresponse status == "success") { webservicebusinessobject\[]\[] incidentlist = searchresponse objlist; foreach (webservicebusinessobject\[] incidentouterlist in incidentlist) { foreach (webservicebusinessobject incident in incidentouterlist) { // since we are just retrieving one field in the selection criteria // (i e incidentnumber), this corresponds to // incident fieldvalues\[0] value when retrieving the results console writeline("incident matches the selection criteria", incident fieldvalues\[0] value); } } } example 2 the following soap example searches for incident records, skips the top 10 records, and returns the next 100 records if you do not specify top in the query \<?xml version="1 0"?> \<soap\ envelope xmlns\ saas="saas services" xmlns\ soap=" http //www w3 org/2003/05/soap envelope "> \<soap\ header/> \<soap\ body> \<saas\ paginationsearch> \<! optional > \<saas\ sessionkey>sessionkey\</saas\ sessionkey> \<! optional > \<saas\ tenantid>tenantid\</saas\ tenantid> \<saas\ objectquery> \<! optional > \<saas\ from object="incident#">\</saas\ from> \<! optional > \<saas\ select all="true">\</saas\ select> \<saas\ orderby> \<! zero or more repetitions > \<saas\ field direction="asc" name="incidentnumber"/> \</saas\ orderby> \</saas\ objectquery> \<saas\ skip>10\</saas\ skip> \</saas\ paginationsearch> \</soap\ body> \</soap\ envelope> you can set the default top maximum value using the appserver webconfig property \<add key="defaultmaxnumberofrecordsrestapi" value="100" /> if you specify the top value as 0, then the paginationsearch method will return 100 records by default
