After the Success of the Check in, the Page should re-load and make sure that its been checked in.

Steps:
  1. Open your SharePoint site and add a CEWP.

  2. Then Copy the below Code and call this function on button click.
  1. <script type="text/javascript">
  2. function checkIn_Success(sender, args)
  3. {
  4. window.location.reload();
  5. }
  6. function checkIn_fail(sender, args)
  7. {
  8. alert('Checkin Failed');
  9. }
  10. function checkIn()
  11. {
  12. var ctx = SP.ClientContext.get_current();
  13. var web = ctx.get_web();
  14. var page = web.getFileByServerRelativeUrl(window.location.pathname);
  15. var listItem = page.get_listItemAllFields();
  16. //We can set any value to any of the property by the below lines.
  17. //listItem.set_item('PublishingPageContent', '{Updated with ECMA}');
  18. listItem.update();
  19. page.checkIn();
  20. page.publish();
  21. ctx.executeQueryAsync(Function.createDelegate(this, checkIn_Success),Function.createDelegate(this, checkIn_fail));
  22. }
  23. </script>
Thanks For reading my blogs!!!.