I have a custom field "webPartId
" in my page property
Whenever user clicks save, i want to update the field
I am not able to get any code snippets for that!
The closest i could reach is finding how to access the page properties via javascript / csom / REST api using below function
function getCurrentListItem(success, error)
{
var context = SP.ClientContext.get_current();
var web = context.get_web();
var currentList = web.get_lists().getById(_spPageContextInfo.pageListId);
var currentListItem = currentList.getItemById(_spPageContextInfo.pageItemId);
context.load(currentListItem);
context.executeQueryAsync(
function(){
success(currentListItem);
},
error
);
}
getCurrentListItem(
function(listItem) {
var webPartId= listItem.get_item('webPartId');
console.log(webPartId);
},
function(sender,args){
console.log(args.get_message());
}
);
Now i want to modify that property,
$("#saveWebPartId").click(function(){
//code to modify the page properties
});
Any client side snippet that can modify the page property is ok to me
currentListItem.set_item('webPartId', '...'); currentListItem.update()
?