Monday 13 June 2016

How to update URL field in SharePoint List using JSOM

 Here is the code to update URL field.
URL will have two properties. One is url and other is description.
Code below is using JSOM.
======================================================
var itemCreateInfo = new SP.ListItemCreationInformation();
var rootUrl = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl;
itemCreateInfo.set_folderUrl(rootUrl + "/Lists/PROJECTS/Folder");//Create item folder inside list
this.oListItem = oList.addItem(itemCreateInfo);
oListItem.set_item('NUMBER', "23");
     var fvalue = new SP.FieldUrlValue();                  
    fvalue.set_url("http://google.com");
    fvalue.set_description("GoogleLink");
oListItem.set_item('URL', fvalue);
oListItem.update();
======================================================

Hope this helps!!!

No comments:

Post a Comment