SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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've got a list item with a field of type URL. As you know, an URL-field consists of two parts: a description and a URL.

Using javascript to update a field that consists of one part is easy, you just do something like

 myItem.set_item('MyTextField', 'MyValue');

But how do I update a URL-field that way? I've tried the following

var URLObj = { URL: 'http://myurl', Description:'this is a description' }; 
myItem.set_item('MyURLField', URLObj);

but it fails during set_item,

Also tried this:

    var URLField = myItem.get_item('MyURLField');
URLField.set_description('this is a description');

But get_item only returns null.

The URL-field I'm trying to set is initially empty, so that's probobly causing some problems, seems like getting empty fields don't return anything ,just null.

So any ideas on what I could try?

share|improve this question
up vote 3 down vote accepted

MSDN says that when assign a value to a list item field you must provide a string, but its not true for complicated fields such url or others. You must use this approach:

var fvalue = new SP.FieldUrlValue();
fvalue.set_description("my description");
newListItem.set_item("linkfield", fvalue);

Useful resource about CSOM javascript classes here

share|improve this answer
Works fine. Can't believe I missed this. Thanks! – Drkawashima Apr 17 '12 at 9:53

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.