Set "assigned To" On Sharepoint Task Using Javascript Object Model
I want to create a sharepoint task and assign it to myself (current user) wtihin the javascript object model. I have the code below, but I think instead of setting a particular use
Solution 1:
You need to do something like below:
<scripttype="text/ecmascript">ExecuteOrDelayUntilScriptLoaded(updateUserField, "sp.js");
functionupdateUserField(){
var ctx = newSP.ClientContext.get_current();
var list = ctx.get_web().get_lists().getByTitle('ListA');
var item = list.getItemById(1);
var assignedToVal = newSP.FieldUserValue();
assignedToVal.set_lookupId(1); //specify User Id
item.set_item("UserField",assignedToVal);
item.update();
ctx.executeQueryAsync(
function() {
console.log('Updated');
},
function(sender,args) {
console.log('An error occurred:' + args.get_message());
}
);
}
</script>
Reference:
Thanks, Jameel
Post a Comment for "Set "assigned To" On Sharepoint Task Using Javascript Object Model"