Thanks Patrick.
Actually, the code I am working with is on page 296 and I have modified it as shown below. I pass the body as a string....and then I added
" <Field Type='DateTime' Name='StartDate'>" + returndate + "</Field>" _
I wanted to put a datetime field in the default task list - in addition to the title and body. I tried it as a string ( s) without the type='DateTime' - either way fails. If I take that line out of the code block the record will post to the task list.
So I guess I'm saying I'm stuck on putting a valid datetime field into the xml that I want to shove back to the web service to update the task list. Does that make sense? If so...how do you recommend I pass back a datetime to the default wss task list? Thanks.
'return id of task or 0 for failure
Public Function CreateTask(ByVal strTitle As String, ByVal strBody As String) As Integer
Dim listName As String
Dim listsservice As lists.Lists
Dim node As XmlDocument
Dim res As XmlNode
Dim resultError As XmlNode
Dim resultId As XmlNode
'Create a var. named rightNow and set it to the current date/time
Dim rightNow As DateTime = DateTime.UtcNow
Dim s As String 'create a string
s = rightNow.ToString
thisXDocument.UI.Alert(s)
' ListName is the GUID for your tasks list
' You can get the ListGuid by viewing the web address URL in
' Modify setting and colums or by adding the list toyour
' form (receive from a sharepoint list) and viewing the manifest
' list GUID for task list @ portal.cafearizona.com
listName = "{4933D782-1775-4B44-8375-5E8FA05219EF}"
' listName = "{7AA664AA-2F14-4D0D-98C4-7FA61B8673EE}"
listsservice = New lists.Lists
listsservice.Credentials = System.Net.CredentialCache.DefaultCredentials
node = New XmlDocument
node.LoadXml("" _
+ "<Batch OnError='Continue' ListVersion='1' xmlns=''>" _
+ " <Method ID='1' Cmd='New'>" _
+ " <Field Name='Title'>" + strTitle + "</Field>" _
+ " <Field Name='Body'>" + strBody + "</Field>" _
+ " <Field Type='DateTime' Name='StartDate'>" + s + "</Field>" _
+ " </Method>" _
+ "</Batch>")
'thisXDocument.UI.Alert("here is the stuff " + strTitle + strBody)
' call the web service
'thisXDocument.UI.Alert(Environment.UserName)
res = listsservice.UpdateListItems(listName, node)
'thisXDocument.UI.Alert("finished calling the listservices")
'Parse the results
Dim nsmgr As XmlNamespaceManager
nsmgr = New XmlNamespaceManager(res.OwnerDocument.NameTable)
nsmgr.AddNamespace("s", "http://schemas.microsoft.com/sharepoint/soap/")
nsmgr.AddNamespace("z", "#RowsetSchema")
'look for the result of ID "1,NEW", matching id="1" and cmd="New above
resultError = res.SelectSingleNode("s:Result[@ID='1,New']/s:ErrorCode", nsmgr)
If (resultError Is Nothing Or Convert.ToInt32(resultError.InnerText, 16) <> 0) Then
Return 0
End If
resultId = res.SelectSingleNode("s:Result[@ID=""1,New""]/z:row/@ows_ID", _
nsmgr)
Return Integer.Parse(resultId.InnerText)