set lookup field & managed meta data field using jsom in sharepoint -
setting lookup field & managed meta data field value using jsom. through jsom need set value list .
setting lookup , managed metadata columns through code
try , modify below sample code:
var clientcontext = new sp.clientcontext(_sppagecontextinfo.webabsoluteurl); var list = clientcontext.get_web().get_lists().getbytitle('testlist'); var itemcreateinfo = new sp.listitemcreationinformation(); var listitem = list.additem(itemcreateinfo); var singlelookupcolumn = new sp.fieldlookupvalue(); singlelookupcolumn.set_lookupid(2); listitem.set_item('customlookup', singlelookupcolumn); var field = list.get_fields().getbyinternalnameortitle("testtaxonomy"); var taxfield = clientcontext.castto(field, sp.taxonomy.taxonomyfield); var taxonomycol = new sp.taxonomy.taxonomyfieldvalue(); taxonomycol.set_label("test"); taxonomycol.set_termguid("23d03b66-5be6-512b-9fe3-ff13b9b4757c"); taxonomycol.set_wssid(-1); taxfield.setfieldvaluebyvalue(listitem, taxonomycol); listitem.update(); clientcontext.load(listitem); clientcontext.executequeryasync(function(){ console.log("success"); },function(){ console.log("error"); });
Comments
Post a Comment