SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a list .

I want update special item of it with javascript.

I created a js file and add this code to it :

 var context = new SP.ClientContext.get_current();
 var web = context.get_web();
 var list = web.get_lists().getByTitle("Sends");
 var salesItem = list.getItemById(90);
 salesItem.set_item("Status", "Closed");

It is work for text field but don't work for Choice field.

How do update a item with javascript?

share|improve this question

Hi for update list item using ECMA script you have to use SP.js

in your code i don't see SP.js reference

use this code i am update task list status column which is choice field

ExecuteOrDelayUntilScriptLoaded(updateProduct, "SP.js"); 
function updateProduct() {
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getByTitle("Tasks");
var product = list.getItemById(1);
product.set_item("Status", "Completed");
context.executeQueryAsync(Function.createDelegate(this, this.success), Function.createDelegate(this, this.failed));

function success()
function failed()
share|improve this answer
my code is like this. for example:When i use my code for 'Title' it is work, but when i use for choice filed don't work. – ar.gorgin Aug 28 '12 at 5:43
dear i update my choice field... U see it's status field of task list ....Please make sure u enter value of choice is in list otherwise it not accept..Thanks – Vishal_Sharepoint Aug 28 '12 at 5:46
also u see the alert??? "Done" or "Problem"?? – Vishal_Sharepoint Aug 28 '12 at 5:47
Yes, 'Closed' is a item of choice field. When i run, get "Done". – ar.gorgin Aug 28 '12 at 5:57
I delete column then add again, now when i update a item it set defualt value for chioce column :( – ar.gorgin Aug 28 '12 at 7:29

Have you verified the Internal name of the Status field is "Status". I think the Internal Field Name is specified wrong in the code.

share|improve this answer
No, i use Internal Name. – ar.gorgin Aug 28 '12 at 5:58

Please try these things:

  1. Validate Internal Name of the column that is used
  2. Validate the choice values of the column. sometimes there might be spaces before or after the values.
  3. Use a success function and check the error message that is returned after the async query.

Hope this helps you!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.