TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nishikant Rath
NA
34
3.1k
why SP.ListOperation.Selection.getSelectedList(ctx) is null?
Mar 14 2018 5:03 AM
I want to delete multiple selected list items based on the selection in a listview sharepoint webpart, but the problem is when the page is in draft mode it is extracting the list id & selected item id but whenever I publish the page it gives null value in the liest id & of course by this the selected items id becomes blank.
Code :
<button onclick="deleteSelectedItem()">Delete</button>
function deleteSelectedItem() {
var context = SP.ClientContext.get_current();
var listID = SP.ListOperation.Selection.getSelectedList(context);
var selectedItems = SP.ListOperation.Selection.getSelectedItems(context);
if (selectedItems.length > 0) {
var lstObject = context.get_web().get_lists().getById(listID);
for (var i = 0; i < selectedItems.length; i++) {
this.lstObjectItem = lstObject.getItemById(selectedItems[i].id);
lstObjectItem.deleteObject();
}
context.executeQueryAsync(Function.createDelegate(this, this.onSuccess), Function.createDelegate(this, this.onFailure));
}
else {
alert("Please Select item !");
}
}
function onSuccess(sender, args) {
alert('Items Deleted');
window.location.href = window.location.href;
}
function onFailure(sender, args) {
alert('Request failed. ' + args.get_message());
Please help me solving this in the published page & explain why it is working in the draft version but not in the published one.
Reply
Answers (
3
)
Server side caching for sharepoint 2013
workflow history and task list are being removed after 60day