Ok, here's the scoop. I have bunch of lists on sub sites that I am rolling up into a list on the parent site. Here is what I have for code:

                            var title = $(this).attr("ows_Title");
                                operation: "UpdateListItems",
                                webURL: "/",
                                async: false,
                                batchCmd: "New",
                                listName: "Initiatives",
                                valuepairs: [["Title", title]],
                                completefunc: function(xData,status){

Problem is that when I execute this script, it always adds a new item, even if the name exists. I tried switching batchCmd to "update" but then if the item doesn't exist it won't add it to the list. Is there something built into SPServices that I could use or do I need to roll my own check?


You have to "roll your own check". User GetListItems to see if there is an existing item and then conditionally either add a new item or update the existing one.

| improve this answer | |
  • Thanks Marc, I just threw the titles in an array and then checked the current title to the ones loaded. Thanks Again – Brenton Pierce May 30 '12 at 15:53

You have to roll your own, there isn't anything built in. The closest is a form operation, SPRequireUnique. You'd need to do a GetListItems operation to first see what's in the list, compare it to what you have and either skip it, update it, or add it.

| improve this answer | |

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.