Search code examples
sharepointsharepoint-2007

SharePoint 2007 - Is it possible to use a variable column name with SPServices quickUpdateListItem?


When using SPServices, is it possible to use a variable to specify the column to be updated?

res = lists.quickUpdateListItem('MyListHere', { ID: ReqD, columnVar : userName });

In the above statement, is it possible to use the variable columnVar in this way? I have not been able to successfully get this to work. It does not throw an error, but it just simply doesn't update.

I'm also not locked into just using SPServices if someone has an alternative solution.


Solution

  • This is possible, but its not very obvious. The library differentiates between what you're passing into the function. If you build an array and then pass that in instead, you can build this dynamically as I was hoping:

    var columnVar = whatever your column name is;
    
    var myArray = new Object();
    myArray['ID'] = ReqD;
    myArray[columnVar] = userName;          
    
    
    res = lists.quickUpdateListItem('MyListHere', myArray);