Using the FindMultipleBusinessObjectsByField Web Method
3 min
returns one or more business objects based on the specified field or value and returns the result as an array of business objects for example, this web method can be used to retrieve all incident records with a status of active, all changes with a type of major, and so on this web method only searches on a single field or value criteria use the search web method if you need more complex queries this web method always returns the results in an array, even if there is only one matching record if you know that only one record will be returned, use the findsinglebusinessobjectbyfield web method instead request syntax frsheatintegrationsearchresponse findmultiplebusinessobjectsbyfield(string sessionkey, string tenantid, string botype, string fieldname, string fieldvalue) parameters sessionkey the session key from the connect web method tenantid the tenant for which the session key is authenticated botype the type of business object to retrieve recid the unique identifier for the business object fieldname the name of the field in the business object to search against fieldvalue the value of the field to search for in the matching record 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 application 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 the following table lists the available status values and describes how to interpret them \<font color="#ffffff">status\</font>\<font color="#ffffff">explanation\</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 cannot find the business objects the objlist field is null inspect the corresponding exceptionreason field to determine why the web method failed one 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 objecttablemap field \<fieldname> is not found in table \<business object># ensure that the field name is spelled correctly, and that it is 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 frsheatintegrationsearchresponse res = frsvc findmultiplebusinessobjectsbyfield(authsessionkey, tenantid, "incident", "status", "active"); if (res status == "success") { webservicebusinessobject\[]\[] incidentlist = res objlist; foreach (webservicebusinessobject\[] incidentouterlist in incidentlist) { foreach (webservicebusinessobject incident in incidentouterlist) { webservicefieldvalue\[] incidentfieldlist = incident fieldvalues; webservicefieldvalue incidentnumberfield = incidentfieldlist singleordefault(f => f name == "incidentnumber"); console writeline("incident matches the selection criteria", incidentnumberfield value); } } }
