Use Case: Create a button that allows user to checkin one or more documents that have been selected. No need for comments, etc. just checkin documents selected. Code below is pretty much a cut/paste from an example, with the checkin() method,
The function noItemSelected (); calls a dialog asking the user to select an item so we can proceed.
var listOrLibrary = 'LibraryLibrary';
var docLibraryTitle = 'Library';
const checkIn = {
icon: 'AccessibiltyChecker',
class: 'btn-outline-primary',
text: 'Check Document(s) In',
visible: true,
click: function() {
const items = fd.control('LibraryLibrary').selectedItems;
if(items.length == 0){
noItemSelected ();
} else {
function(items) {
var library = pnp.sp.web.lists.getByTitle(docLibraryTitle);
library.getListItemEntityTypeFullName().then(function(entityTypeFullName){
for(var i = 0; i < items.length; i++){
library.items.getById(items[i]).checkin();
}
});
}
}
}
}
fd.control('LibraryLibrary').ready(function(dt) {
dt.buttons.push(checkIn);
});
POSSIBLE ERROR:
a) Use of function(items)
b) library.items.getById(items[i]).checkin();
There is a syntax type error,. or more, in here somewhere since the entire JS file fails when this code in injected into the form.