Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

New Post: SPServices Add/update list item: Dynamically creating valuepairs

$
0
0
Hi,

I tried dynamically creating valuepairs but it is not adding/updating list item. Here is my code
        var columnsForInsert = [];
        columnsForInsert[0] = [['Title'], [productPlan]];
        columnsForInsert[1] = [['Product_x0020_Name'], [productName]];
        columnsForInsert[2] = [['Product_x0020_Plan_x0020_Categor'], [productPlanCategory]];
        columnsForInsert[3] = [['Fiscal_x0020_Year'], [fiscalYear]];
        columnsForInsert[4] = [['Plan_x0020_Status'], [planStatus]];
        ....
        ....
        ....
        ....
                            // Create New List Item
                            $().SPServices({
                                operation: "UpdateListItems",
                                async: false,
                                batchCmd: "New",
                                listName: "SEB Product Planning",
                                valuepairs: columnsForInsert,
                                completefunc: function (xData, Status) {
                                    alert("List Item successfully Created.");
                                }
                            }); // End of SPServices UpdateListItems
If i manually create the valuepairs as

Working option:
valuepairs: "[['Title',Updates test], ['Product_x0020_Name',1;#ABC], ['Product_x0020_Plan_x0020_Categor',3;#New & Enhancements], ['Fiscal_x0020_Year', 2;#2014], ['Plan_x0020_Status',4;#Pending]]",

This approach creates the iteam. But I have a bunch of optional date fields for which I cannot insert null. I was thinking of dynamically creating the valuepairs omitting fields with blank data.

Note: When i debug in IE or Firefox, I don't see any difference between the working option and columnsForInsert.

Any help is greatly appreciated.

With regards,
Shankar

Viewing all articles
Browse latest Browse all 6517

Trending Articles