Posts Tagged ‘To-Do’

SWS CreateSiteTask Method

April 29, 2011 Leave a comment

Creates a task item for a specified site. The Store application creates system-generated task list items as well.


Name DataType Is Required
Body String Required
Description The text of the task note.
DueDate DateTime Required
Description The date and time by which the task list item should be completed.
Header String Required
Description The subject line of the task.
Priority eTaskPriority Required
Description The task’s priority level.
Available values:

  • Low
  • Medium
  • High
Ref Long Optional
Description Only necessary if the RefType is provided. Refers to the ID number of the account or rental the task is tied to.
RefType eTaskRefType Optional
Description The reference type to which the task item is associated.
Available values:

  • None
  • Account
  • Rental
  • Reservation_Quote
  • Unit
SiteID Long Required
Description The site’s ID number the task will be attached to. This can be found using the GetSiteList method.
Source eTaskSource Required
Description The source of this task list item.
Available values:

  • None
  • SWS
  • Call_Center
  • Website
  • Kiosk
Type eTaskType Required
Description The task list type.
Available values:

  • Task_To_Do
  • Appointment
  • Followup
  • Maintenance
  • Reservation
  • Other

Returned Parameters

Name DataType
TaskID Long
Description The task item’s ID number.


As with every method we need to pass in credentials. We do this with the LookupUser request object.

We’ll assume you’ve got a web reference, let’s name it SWS, in your Visual Studio project.  At this point we need to our objects.  We’ll need the standard service object, a CreateSiteTask request object and a CreateSiteTask response object. We can define and create those like this:

// Create request and response objects
SWS.WSSoapClient service = new SWS.WSSoapClient();
SWS.CreateSiteTask_Request request = new SWS.CreateSiteTask_Request();
SWS.CreateSiteTask_Response response;

Here’s my sample code of the Request object.

// basic task request
request.Header = "Test task";
request.Body = "This is a test task.  Please ignore.";
request.SiteID = 123456;
request.DueDate = DateTime.Today.AddDays(5);
request.Type = SWS.eTaskType.Followup;
request.Source = SWS.eTaskSource.Website;
request.Priority = SWS.eTaskPriority.Medium;
request.RefType = SWS.eTaskRefType.Account;
request.Ref = 123456; //AcctID based on RefType

Finally we can call the method and pass across the login object and the request object to create our notes. It’s a good idea to do this in a Try Catch block.

// Call the method that will load the response object
  response = service.CreateSiteTask(user_request, request);
catch (Exception ex)

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 SWS Methods.