I'm using sp.js and I'm confused, how to update property of property? For example I have:

Item: { 
    Image: { 
        Url: 'xxx', 
        Description: 'xxx' 

I've tried .load(Item) and then image = Item.get_item('Image') but image.set_item('Url', 'smthnew') and .update() fails...

How to actually update Image.Url via .update()?

Thanks a lot!

  • show your whole code block – Mike May 12 '17 at 17:17

Looks like this is Hyperlink or picture column.

To update it using JSOM, try the below code:

var clientContext  = new SP.ClientContext();          
var web = clientContext.get_web();          
var lists = web.get_lists();     
var oList = lists.getByTitle("TestList");     
oListItem = oList.getItemById(1);     
var urlValue = new SP.FieldUrlValue();
urlValue.set_description("custom image description");
oListItem.set_item("Image", urlValue);     
    }, function(){
| improve this answer | |
  • Yes, looks valid, gonna try. Truly it is right. So each time I face some complex property I should find reflection of it in some sp object? Like URL object for this kind of field. Thanks – Appeiron May 12 '17 at 18:16
  • Glad i could help ! Please consider marking it as answer :) Also, you can can follow this link Update list items using JSOM – Gautam Sheth May 12 '17 at 18:23
  • Well, at least now I know it's called JSOM -_- – Appeiron May 12 '17 at 18:24

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.