SWS2 GetDataView Method
This method is designed to allow access to specific database views to retrieve data. This method was created so that when a data set not currently available in reports or other functions is required, the view can be created within the database and accessed without creating additional API methods. This method does not do any logic, it simply retrieves the view based on the parameters specified. Each view will have a unique parameter collection and that information will need to be obtained from Yardi before the view can be accessed. The parameters collection will need a parameter object that includes filter type (equal, not equal, greater than, etc.), the parameter name which is the field name in the view, and the parameter value which is the value on which to filter. The data is returned as a serialized DataTable.
Parameters
Name | DataType | Is Required |
---|---|---|
OrgID | Long | Required |
Description | The organization ID number for which you are accessing the data. | |
SiteID | Long | Optional* |
Description | The site’s ID number. This can be found using the GetSiteList method. *This is required if the view is a site level only view. |
|
ViewName | String | Required |
Description | This is a list of currently available views:
|
|
FilterType | Decimal | Required |
Description | Selects the type of filter to use in the search. Available filter values:
|
|
ParameterName | String | Required |
Description | Indicates the name of the parameter for which you wish to apply the filter. See the ViewName above for the available parameters. | |
ParameterValue | String | Required |
Description | Indicates the value of the parameter for which you wish to apply the filter. |
Returns
Name | DataType |
---|---|
GetDataViewResult | DataTable |
Description | A data table that contains all rows meeting the filter parameters. |
Example
We’ll assume you’ve got a web reference, let’s name it Store, in your Visual Studio project. At this point we need to create our objects. We’ll need the standard service object, a GetDataView request object that contains one or more ParameterValues object(s) and a DataTable object for the response. We can define and create those like this:
// Create a request and response objects
Store.GetDataView_Request request = new Store.GetDataView_Request();
Store.ParameterValues params1 = new Store.ParameterValues();
Store.ParameterValues params2 = new Store.ParameterValues();
System.Data.DataTable resp = new System.Data.DataTable();
Now we set up the parameters for our request. Each parameter you are filtering by should have a filter type (listed below), a parameter name which is the name of the field you wish to filter on (click on view names above for the list of available fields) and the value on which to filter.
//Add deposit request object
params1.FilterType = 3;
params1.ParameterName = "end_date";
params1.ParameterValue = DateTime.Today.AddDays(-30).ToString();
params2.FilterType = 5;
params2.ParameterName = "end_date";
params2.ParameterValue = DateTime.Today.ToString();;
request.OrgID = 123456;
request.SiteID = 123456;
request.ViewName = "move_out_list_v";
request.Parameters = new Store.ParameterValues[] { params1, params2};
Finally we can call the method and pass in the request object to retrieve our data table. It’s a good idea to do this in a Try Catch block.
// Call the method that will load the data
try
{
resp = client.GetDataView(request);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Note that if something goes wrong the service will respond with an exception. You’ll want to take a look at that message returned in that exception so it can be debugged.
For a full list of methods see SWS2 Methods.