After the Success of the Check in, the Page should re-load and make sure that its been checked in.
Steps:
- Open your SharePoint site and add a CEWP.
- Then Copy the below Code and call this function on button click.
- <script type="text/javascript">
-
- function checkIn_Success(sender, args)
- {
- window.location.reload();
- }
- function checkIn_fail(sender, args)
- {
- alert('Checkin Failed');
- }
- 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();
-
-
- listItem.update();
-
- page.checkIn();
- page.publish();
- ctx.executeQueryAsync(Function.createDelegate(this, checkIn_Success),Function.createDelegate(this, checkIn_fail));
- }
- </script>
Thanks For reading my blogs!!!.