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.

  • Really? You edited my question to fix 'doesnt' to 'doesn't' ...? – dah97765 Jun 20 '12 at 21:14
  • I have answer but I can't post it until more than 8 hours passes. I'll update soon :) – dah97765 Jun 20 '12 at 21:18

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); 

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.