SWS SearchBy Method
Allows you to search for a customer name, unit number, phone number, or rental ID. The search can be performed for the entire organization or for just a specific site. This will return a record for each contact and each rental on an account.
Parameters
Name | DataType | Is Required |
---|---|---|
OrgID | Long | Optional* |
Description | The organization’s ID number. *Either an OrgID or SiteID is required. |
|
SearchTerm | String | Required |
Description | The parameter to search for. | |
SearchType | SearchTypes | Required |
Description | Tells the system what fields to look at in the search. Available values:
|
|
SiteID | Long | Optional* |
Description | The site’s ID number. This can be found using the GetSiteList method. *Either an OrgID or SiteID is required. |
Returned Parameters
Name | DataType |
---|---|
ACCT_CONTACT_NAME_SEARCH | String |
Description | The field in Store used when an “Account/Contact” search is performed. |
ACCT_ID | Long |
Description | The account’s ID number. This is returned when you use the CreateNewAccount method or can be retrieved with the SearchBy method. |
ACCT_NAME | String |
Description | The name on the account. This may differ from the primary contact’s name in some instances, such as a business account or a guardianship account. |
AFFILIATE_ID | Long |
Description | The affiliated organization’s ID number. |
BASIC_NAME_SEARCH | String |
Description | The field in Store used when an “Account Name” search is performed. |
CONTACT_FULL_NAME | String |
Description | The full name of the contact in the format of “First Last”. |
CONTACT_ID | Long |
Description | The rental contact’s ID number. |
DISPLAY_RENTAL_STR | String |
Description | The display name of the rental as it appears in Store. |
FIRST_NAME | String |
Description | The first name of the contact. |
LAST_NAME | String |
Description | The family or last name of the contact. |
NETWORK_NAME_SEARCH | String |
Description | The organization’s search field which includes the account name, the organization name and the site name. |
OBJECT_ID | Long |
Description | The object’s ID number. This is maintained through rentals. |
ORG_ID | Long |
Description | The organization’s ID number. |
PHONE | String |
Description | The contact’s phone number. |
PHONE_CONTACT_NAME_SEARCH | String |
Description | One of the fields in Store used when a “Phone Number” search is performed. |
PHONE_SEARCH | String |
Description | One of the fields in Store used when a “Phone Number” search is performed. |
PHONE_TYPE | String |
Description | Describes the type of phone number returned for the contact. Available values:
|
PTD | DateTime |
Description | The PTD of the returned rental. |
QUICK_SEARCH | String |
Description | The field in Store used when an “Quick Search” search is performed. |
RENTAL_ID | Decimal |
Description | The rental record’s ID number. |
RENTAL_STATUS | Integer |
Description | The textual value for the rental status of the rental. Available values:
|
RSTAT_RAW | Decimal |
Description | The numeric value for the rental status of the rental. Available values:
|
SITE_ID | Long |
Description | The site’s ID number where the unit is located. |
SITE_NAME | String |
Description | The site’s name where the unit is located. |
UNIT_NUMBER | String |
Description | The unit’s number as assigned by the organization. This is not the UnitID. |
UNIT_SEARCH | String |
Description | The field in Store used when a “Unit Number” search is performed. |
UNIT_STATUS | String |
Description | The rental status of the unit. Available values:
|
Example
As with every method we need to pass in credentials. We do this with the LookupUser request object.
We will assume you have a web reference, let us name it SWS, in your Visual Studio project. At this point we need to define our objects. We will need the standard service object, a SearchBy request object, and a SearchBy response object. We can define and create those like this:
// Create a request and response objects
SWS.WSSoapClient service = new SWS.WSSoapClient();
SWS.SearchBy_Request request = new SWS.SearchBy_Request();
SWS.SearchBy_Response response;
Here is a sample code of the request object for the QuickSearch option:
// SearchBy Request
request.OrgID = 123456;
request.SiteID = 123456;
request.SearchTerm = "Joe";
request.SearchType = SWS.SearchTypes.QuickSearch;
Finally we can call the method and pass across the login object and the request object to retrieve our requested information. It’s a good idea to do this in a Try Catch block.
// Call the method that will load the response object
try
{
response = service.SearchBy(user_request, request);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Note that if something goes wrong the service will respond with an exception. You will want to capture the message in the exception so it can be debugged.
For a full list of methods see SWS Methods.
Updated Mar. 19, 2015: We’d noted that when calling our NameSearch function and PhoneSearch function, there were occasions where non-related account data was being returned. When an account had multiple rentals, some of which were terminated, we found that there were occasions where the terminated account information would be returned. We have corrected that issue.
Updated July 17, 2014: We have made changes to improve the performance of the SearchBy function for all searches except QuickSearch, which is already running at maximum efficiency. These changes will reduce response times by at least 50%, however, all data returned should remain the same.