0

I've been banging my head against the wall for a bit too long now.

I've been using the lists.asmx webservice for my Sharepoint server (2007, so no client object model unfortunately) and I've been able to successfully update every desired item field on the server...except for dates. And I'm not referring to read-only dates. Just dates that can be entered in mm/dd/yyyy format for a list item on the site itself.

I'm in C#, and if anyone can see a potentially simple correction to my CAML (which is where the problem is, I'm fairly sure) I would most appreciate it.

batchElementGlobal.InnerXml = "<Method ID='1' Cmd='Update'>" +

        "<Field Name='ID'>" + GlobalVariables.ID + "</Field>" +
        "<Field Name='Title'>" + tempExperiment.ProjName + "</Field></Method>" +

        "<Method ID='1' Cmd='Update'>" +
        "<Field Name='ID'>" + GlobalVariables.ID + "</Field>" +
        "<Field Name='Experiment_x0020_Lead'>" + tempExperiment.ProjLead + "</Field></Method>" +

        "<Method ID='1' Cmd='Update'>" +
        "<Field Name='ID'>" + GlobalVariables.ID + "</Field>" +
        "<Field Name='Technology_x0020_Partner'>" + tempExperiment.TechPartner + "</Field></Method>" +

        "<Method ID='1' Cmd='Update'>" +
        "<Field Name='ID'>" + GlobalVariables.ID + "</Field>" +
        "<Field Name='IT_x0020_Functional_x0020_Area'>" + tempExperiment.FunctionalArea + "</Field></Method>" +

        "<Method ID='1' Cmd='Update'>" +
        "<Field Name='ID'>" + GlobalVariables.ID + "</Field>" +
        "<Field Name='Start_x0020_Date'>" + strProjStartDateTime + "</Field></Method>" +

        "<Method ID='1' Cmd='Update'>" +
        "<Field Name='ID'>" + GlobalVariables.ID + "</Field>" +
        "<Field Name='End_x0020_Date'>" + strProjEndDateTime + "</Field></Method>" +

        "<Method ID='1' Cmd='Update'>" +
        "<Field Name='ID'>" + GlobalVariables.ID + "</Field>" +
        "<Field Name='Read_x0020_Out_x0020_Date'>" + strProjReadoutDateTime + "</Field></Method>" +

(This is a stripped down version. Wanted to show how I formatted multiple-words fields and that they work. The strProjXXXDateTime strings are all in the same format. eg: "6/18/2012")

There may be some sort of formatting for dates on SharePoint's end, but I figured that since you can input the date in a standard string format on the site itself, using a string would totally be an option. Perhaps not? If you need anything else please let me know.

Thanks!

(Sidenote -- in past tests, I think I concluded that each field needs its own method section, which I thought was odd. Even though it's updating one item, it needed the differentiation. Was that just a fluke? Can I put all of the field's under one method?)

Nate Frueh
  • 79
  • 1
  • 8

2 Answers2

0

...yep. Silly mistake.

http://msdn.microsoft.com/en-us/library/lists.lists.updatelistitems(v=office.12).aspx

Or, for those of you playing at home who don't like clicking links: 2006-1-11T09:15:30Z

I definitely tried converting my date to this format, but apparently it wasn't specific enough.

This just did the trick. Hopefully, others who ever run into this silly roadblock find this useful.

That's all. :)

Nate Frueh
  • 79
  • 1
  • 8
0

In an ItemUpdating (SPItemEventReceiver) for a custom list, in order to update the date for a custom date time field (DateOnly mode), I was forced to use :

SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Today)

Strange way to handle dates ;)

Le_Fredo
  • 639
  • 3
  • 5
  • I heard rumors that updating dates were somewhat easier when using Sharepoint services, however I believe that each list still has their own custom datetime paramters, making it equally misleading. It's just *occasionally* usually helpful to know what those parameters are... – Nate Frueh Aug 02 '12 at 13:05