SWS UpdateUnitStatus Method
Allows the user to place a hold on a rental item to ensure its availability during the set up process to avoid duplicate use of the item. It also allows the ability to remove a hold on a rental item.
Parameters
Name | DataType | Is Required |
---|---|---|
PutOnHold | Boolean | Required |
Description | Indicates if the unit should be put on hold (“True”) or if it should be removed from hold (“False”). | |
SiteID | Long | Required |
Description | The site’s ID number. This can be found using the GetSiteList method. | |
UnitID | Long | Required |
Description | The unit’s ID number. This is returned when you use any of the GetSiteUnitData calls and is maintained through rentals. | |
Version | Decimal | Required |
Description | The unit’s version number which serves to prevent duplicate use of the unit. |
Returned Parameters
Name | DataType |
---|---|
NewVersion | Decimal |
Description | The unit’s new version number which serves to prevent duplicate use of the unit. |
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, an UpdateUnitStatus request object, and an UpdateUnitStatus response object. We can define and create those like this:
// Create a request and response objects
SWS.WSSoapClient service = new SWS.WSSoapClient();
SWS.UpdateUnitStatus_Request request = new SWS.UpdateUnitStatus_Request();
SWS.UpdateUnitStatus_Response response;
Here is a sample code of the request object:
// UpdateUnitStatus Request
request.SiteID = 123456;
request.UnitID = 123456;
request.Version = 12;
request.PutOnHold = true;
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.UpdateUnitStatus(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 June 2, 2014: Corrected code to properly update the unit hold status by checking the current status of the unit before updating.