This project has moved. For the latest updates, please go here.

IGNORE THIS THREAD REAL ISSUE WAS NOT USING INTERNAL NAMES UpdateListItems with numeric sharepoint 2010 field

Jun 11, 2013 at 4:13 PM
I am trying to use value pairs with UpdateListItems to update a list .... all other fields will update correctly however when I try to update a numeric column I get the dreaded

<ErrorCode>0x81020014</ErrorCode><ErrorText>One or more field types are not installed properly. Go to the list settings page to delete these fields.</ErrorText>

I tried dividing by 1 the value I stick in the array but that didn't work... even hard coding a number doesn't work... any thoughts?

// a function to save the list items
function saveListItem(){
if(!validateThisForm()){
    return false;
}

var valuePairs = new Array();
var checkedItems = new Array();



$(".textField").each(function(){
    namePair = new Array();
    namePair[0] = $(this).attr('name');
    namePair[1] = $(this).val();
    if( $(this).is(".isNumeric")  ){
//HERE I AM HARDCODING 9 and it still FAILS!
        namePair[1] = 9;
        alert( namePair[0] + '  ' + namePair[1] )
    }
    valuePairs.push ( namePair );
 });


var completefunc = function(xData, Status) {

                    loadList();
                    }  

                }

if( ! isEdit)
{  
$().SPServices({
        operation: "UpdateListItems",
        async: false,
        batchCmd: "New",
        listName: listName,
        valuepairs:valuePairs,         
        completefunc:completefunc        
    }); 
}
else
{

 $().SPServices({
        operation: "UpdateListItems",
        async: false,
        batchCmd: "Update",
        listName: listName,
        valuepairs:valuePairs,
        ID:currentListId,
        completefunc: completefunc      
     });
}    
}


PS for those who have strugged using jquery datepicker and it blows up on a sharepoint date time field I use
$(".isDate").each(function(){
    namePair = new Array();
    namePair[0] = $(this).attr('name');
    namePair[1] = $(this).val();
    if( namePair[1]){
        namePair[1] =getDateTime(namePair[1] );
    }

    valuePairs.push ( namePair );
 });
function getDateTime(date){
    var dateArray = date.split("/");
    d = dateArray[2] + "-" +   dateArray[0] + "-" + dateArray[1];

    return d;
}
Coordinator
Jun 12, 2013 at 1:03 AM
Edited Jun 12, 2013 at 9:08 PM
You should be able to simple pass in the number. I'm not sure what's going on above as you're jumping around a little. I always suggest trying the simplest example, with no variables, first.

Something like:
 $().SPServices({
        operation: "UpdateListItems",
        async: false,
        batchCmd: "Update",
        listName: listName,
        valuepairs: [["ColumnName1", numValue]],
        ID: 1,
        completefunc: null   
     });

M.
Jun 12, 2013 at 11:33 AM
sympmarc: thanks for the quick reply ... after further investigation it appears that the fact the column is defined as numeric might be a red herring ... I am working on a pre-existing list with list items ... do you know what effect

1) if a column was created in sharepoint after a list item was entered and then I try to use spservices to update that new column on the old list item? or
2) if a list has versioning and saves last 5 versions but I can only see latest version and try to update the new column
3) if a list requires content approval and I try to update the new column

last question: when retrieving a list item, does sharepoint only return the fields that have values? thanks!
Coordinator
Jun 12, 2013 at 9:10 PM
You should be able to update anything that you can do through the UI. Keep in mind that if you have check out/check in turned on, you'll need to check out the item before you update it.

And yes, SharePoint stores a sparse matrix, so only fields which have values will be in the returned data.

M.
Jun 13, 2013 at 3:55 PM
sympmarc: the issue turned out to be using a display name and not internal name for a field... but I want to personally thank you for taking the time to answer
Coordinator
Jun 13, 2013 at 7:32 PM
That'll get you every time. Glad you caught it!

M.