Need some assistance on a bit of JQuery for writing to a MOSS 2007 list. I have the following spot of code. If I run it with just the title field, it works fine, adding additional fields doesn't work. The alert note at the bottom shows Status as success and the newID is undefined.

    operation: "UpdateListItems",
    async: false,
    listName: "Arrest",
    updates: "<Batch OnError='Continue' PreCalc='TRUE'>" +
                "<Method ID='1' Cmd='New'>" +
                    "<Field Name='Title'>" + title + "</Field>" +
                    "<Field Name='Date_x0020_of_x0020_Arrest'>" + dateOfArrest + "</Field>" +
                    "<Field Name='Subject_x0020_Information'>" + subjectInfo + "</Field>" +
                    "<Field Name='Charges'>" + charges+ "</Field>" +
                    "<Field Name='Significant_x0020_Activity'>" + sigAct + "</Field>" +
                "</Method>" +
    completefunc: function (xData, Status) {
        //get the ID for the newly created Issue
        var newID = $(xData.responseXML).find("[nodeName=z:row]").attr("ows_ID");
        alert(Status + " " + newID);

Date of Arrest is a date field
Subject Information is a multiline note
Charges is a chouce field
Significant Activity is a lookup, and I'm sending it the ID of the item to lookup to.



What's the format of the Date of Arrest string? I needs to be in ISO8601 format, like 2011-02-08T16:42Z (from what I remember) to be added to the list this way, otherwise the whole add operation fails.

  • Ahhh... is there is a SPService util for converting a date into this format? Ot an easy way with JQuery? – David Lozzi Feb 8 '11 at 21:51
  • Where's it coming from in the first place? Not sure of a method out in the wild, but you could probably do it with some JavaScript jiggery-pokery. – James Love Feb 8 '11 at 22:00
  • Test it with a sample date in that format (hard-coded) first, though, to see if I'm right or wrong. – James Love Feb 8 '11 at 22:00
  • 1
    (third comment! :O ) Just found this linked on a thread in StackOverflow, a Date library! has a toISOString() method: code.google.com/p/datejs – James Love Feb 8 '11 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.