Is there an easy way to create a shortcut to check-in or check-out an item of a list (or library)? I see a JS is making this work, but I would get the URL/Command that is created in order to put a shortcut ion the page avoiding user to go to the ribbon and use the icon there.
I can imagine something like




To check in:

 <script type="text/javascript">

 function checkIn_Success(sender, args)
           function checkIn_fail(sender, args)
             alert('Something went wrong');
           function checkIn()
               var ctx = SP.ClientContext.get_current();
               var web = ctx.get_web();
               var page = web.getFileByServerRelativeUrl(window.location.pathname);

                 var listItem = page.get_listItemAllFields();
 //We can set any value to any of the property by the below lines.
                 //listItem.set_item('PublishingPageContent', '{Updated with ECMA}');

               ctx.executeQueryAsync(Function.createDelegate(this, checkIn_Success),Function.createDelegate(this, checkIn_fail));

To checkout

 function CheckOutFile() {
             var clientContext = SP.ClientContext.get_current();            
                 var webSite = clientContext.get_web();
                 this.list = webSite.get_lists().getByTitle("Shared Documents");
                 this.item = list.getItemById(1);
                 this.file = this.item.get_file();
                 clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadSuccess), Function.createDelegate(this, this.OnLoadFailed));            
  • Thanks, but it is not clear for me how should I pass the details (list name, item ID) to the function – Marpio Jan 16 '17 at 13:13
  • SP.ListOperation.Selection.getSelectedItems(); this function will give you selected list items from the OOTB list. You can get the list guid as well from the Selection method – dsouzajoel22 Jan 16 '17 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.