Creating a new list item using UpdateListItems

Sep 17, 2013 at 7:36 PM
Can someone provide information on how to use the UpdateListItems service to create new list items in list "B" from the information entered into list "A"? I am attempting to create a new associate list item based on the details entered into a project list item. The project list item will have details such as title, project ID, assigned resources, etc. I need to create a new associate list item in list "B" for each assigned resource indicated, while reusing the project record data.

List A Example: (Title / ProjectID / Assigned Resources)
Project SP / 1234 / David, Sally, Walter
individual List B Examples:
Project SP / 1234 / David
Project SP / 1234 / Sally
Project SP / 1234 / Walter
Heres a snippet of the code Im using which essentially creates a new list item at PreSave until all assigned resources have been used.

var revisedResources = updatedARvalue.split(";");
var rLength = revisedResources.length
 var singleAR="",i=rLength;
while (i != 0)
{
var singleAR = revisedResources.shift();
$j().SPServices({
    operation: "UpdateListItems",
    batchCmd: "New",
    listName: "{CAC80717-DB02-4140-BF50-0F1EA65CD70A}",      
valuepairs: [["ID",i],["Title",prTitle],["ProjectID",prID],["Assigned_x0020_Resource",singleAR]],
        debug: false,
        completefunc: null 
});
--i;
}

I dont know why this is not working properly; any help is appreciated.
Coordinator
Sep 18, 2013 at 1:28 AM
William:

Your syntax seems a bit odd to me, though it seems as though it should work. When you say it's "not working properly", what is the result you're seeing?

M.
Oct 10, 2013 at 6:45 PM
In valuepairs, you're pushing an ID. You can't assign an ID on a new item (it's an autonumber). Try it without pushing that field.

Geoff