Infopath Book Sample page 297 - datetime format - InfoPath Dev
in

InfoPath Dev

Infopath Book Sample page 297 - datetime format

Last post 04-15-2006 11:54 PM by Patrick Halstead. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 09-12-2005 11:48 AM

    Infopath Book Sample page 297 - datetime format

    Okay....I have found a format for a datetime constant that seems to work with my web services and display correrctly with the out - of - box wss views.

    For example..if I set my string to "2004-11-09T13:30:00.0000000-00:00" and use this code to update list via web service....I like the results. Now I want to use the same format in the "events" wss list and see if it will take the string.

    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'>" + "2004-11-09T13:30:00.0000000-00:00" + "</Field>" _
    + " </Method>" _
    + "</Batch>")
  • 09-12-2005 07:51 PM In reply to

    Re: Infopath Book Sample page 297 - datetime format

    My mistake. ""1.New"" is not the same as ""1,New"". I apologize to the members of the forum for a dumb question. Thought I had looked that over many - many times in the past 36 hours.

    BTW....were do I find documentation of xxx.namespace("z, "#RowsetSchema")?

  • 09-13-2005 01:31 AM In reply to

    Re: Infopath Book Sample page 297 - datetime format

    Hi Cafe Arizona and welcome to our forum,
    I'm glad to hear that you solved the problem. Documentation for xxx.namespace? I have no clue. Did you check Google? You can search both our forum and our website for namespace and fine a bunch of stuff. In addition, please take a look at the InfoPath SDK. My guess, however, is that Google will help the most.

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 09-13-2005 02:18 PM In reply to

    Re: Infopath Book Sample page 297 - datetime format

    Patrick, I'm still working the example you have on page 297 of the book you co-authored. I'm having a bit of a struggle passing a datetime to the sample task list....I have the other part of your sample working fine.
    What is the trick to getting a value back to the "startdate" field in the task list? with vb.net.......Thanks....Craig


  • 09-13-2005 02:57 PM In reply to

    Re: Infopath Book Sample page 297 - datetime format

    Hi Craig,
    Thanks for the context. On page 297, there are the following lines of code:
    Dim nsmgr As XmlNamespaceManager
    nsmgr = new XmlNamespaceManager(res.OwnerDocument.NameTable)
    nsmgr.AddNamespace("s", "http://schemas.microsoft.com/sharepoint/soap/")
    nsmgr.AddNamespace("z", "#RowsetSchema")

    You can find documentation on AddNamespace by looking in help documents for VB.NET or on the MSDN website. Just search for XmlNamespaceManager. There should be a method for AddNamespace.

    What else?

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 09-13-2005 03:16 PM In reply to

    Re: Infopath Book Sample page 297 - datetime format

    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)
  • 09-14-2005 10:45 PM In reply to

    Re: Infopath Book Sample page 297 - datetime format

    Hi Craig,
    I'm wondering if it isn't because he date time is different between the SQL datatypes in SharePoint and the XSD datatypes in InfoPath. I would think string would work but may require special formatting. You may look at the date time format generated when you add a task directly to SQL and see if you can do the same. I'm sure someone else - like Matthew Blain, who wrote the chapter - would have more info, but he's hard to contact ever since he went to work for Google.

    Anyway, please investigate a little more and if you still are stuck, I'll ask my SharePoint stud developer to take a look at it.

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 04-14-2006 04:01 AM In reply to

    • gaurs
    • Not Ranked
    • Joined on 04-04-2006
    • India
    • Posts 12

    Re: Infopath Book Sample page 297 - datetime format

    I am stuck with the same problem. I am unable to update the datetime column on my custom list using the lists web service. Did you get an answer to this? If so, can you please help? Thanks.
  • 04-15-2006 11:54 PM In reply to

    Re: Infopath Book Sample page 297 - datetime format

    Hi Gaurs,
    I replied to your other post regarding that issue. Please don't double post. I will delete double posts.
    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.