Skip to main content

Posts

Showing posts from May, 2017

how to set any SP.Field Value with JSOM (Javascript) Sharepoint 2013

function createListItem() { var clientContext = new SP.ClientContext(_spPageContextInfo.siteAbsoluteUrl); var oList = clientContext.get_web().get_lists().getByTitle('TestList'); var itemCreateInfo = new SP.ListItemCreationInformation(); this.oListItem = oList.addItem(itemCreateInfo); //Single line of text oListItem.set_item('Title', 'My New Item!'); //Single Choice oListItem.set_item('PetkaChoiceDrop', 'Enter Choice #1'); //Multi Choice var petkaChoiceMultiArray = new Array("Enter Choice #1","Enter Choice #2"); oListItem.set_item('PetkaChoiceMulti', petkaChoiceMultiArray); //Single Lookup var PetkaLookupSingle = new SP.FieldLookupValue(); PetkaLookupSingle.set_lookupId(2); oListItem.set_item('PetkaLookup', PetkaLookupSingle); //Multi Lookup var lookupsIds = [1,2]; var lookups = []; for (var ii in lookupsId...