Quantcast
Viewing all articles
Browse latest Browse all 6517

New Post: UpdateListItems Only Updates the First Record

I'm running a script that enumerates the folders of a list. For each folder, I look up it's existing name in another list, return the new name from the second list and update the folder name to the new name returned. The lookups/returns are working fine. I want the folder "Title" and "BaseName" to change to the new name returned. Strangely, it succeeds completely for the first folder it attempts to update. However, subsequent folders only change their "Title" while the "BaseName" remains unchanged. I have tried several different methods and keep getting the same results. The returned XML for each UpdateListItem operation doesn't indicate any errors. Here's a snippet of what I'm doing:
    //Enumerate the folders of the target list
    $().SPServices({
        operation: "GetListItems",
        async: false,
        listName: "UserMessages,   //defalt view is by folder
        CAMLViewFields: "<ViewFields Properties='True' />",
        CAMLQuery: "<Query><Where><Eq><FieldRef Name='FSObjType' /><Value Type='Integer'>1</Value></Eq></Where></Query>",
        CAMLQueryOptions: "<QueryOptions><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns></QueryOptions>",
        completefunc: function(xData, Status) {
            //I've confirmed the GetListItems oop returns a list of folders
            $(xData.responseXML).SPFilterNode("z:row").each(function() {
                strWPUserName = $(this).attr("ows_Title");
                lngUserMsgFolderID = $(this).attr("ows_ID");
                strAFNetUsername = $(xmlAFNetCrossRef).find("[ows_WPUserName=" + strWPUserName + "]").attr("ows_AFNetUserName");   //This is the lookup to the second list (stored XML)--it works
                if(strAFNetUsername != undefined) {
                    //console.log(strWPUserName + " = " + strAFNetUsername);
                    //This operation updates "Title" and "BaseName" for the first record, only updates "Title" for each record after that(?????)
                    $().SPServices({
                        operation: "UpdateListItems",
                        async: false,
                        batchCmd: "Update",
                        listName: strListUpdate,
                        valuepairs: [["Title", strAFNetUsername], ["BaseName", strAFNetUsername]],
                        ID: lngUserMsgFolderID,
                        completefunc: function(xData, Status) {
                            console.log(xData.responseText);
                        }
                    });
                }
            });
        alert("Completed updates");
        }
    });
I've run out of ideas.....

Viewing all articles
Browse latest Browse all 6517

Trending Articles