Today, I will tell you about Checkin the Page in SharePoint 2013 using Javascript. After the Success of the check in, the Page ought to re-load and ensure that its been checked in. Now, open your SharePoint web site and add a CEWP. And then Copy the below Code and call this function on button click. Write the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<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(); //We can set any value to any of the property by the below lines. //listItem.set_item('PublishingPageContent', '{Updated with ECMA}'); listItem.update(); page.checkIn(); page.publish(); ctx.executeQueryAsync(Function.createDelegate(this, heckIn_Success),Function.createDelegate(this, checkIn_fail)); } </script> |
SharePoint 2013 Hosting Recommendation
HostForLIFE.eu’s SharePoint 2013 Hosting solution offers a comprehensive feature set that is easy-to-use for new users, yet powerful enough for the most demanding web developer expert. Hosted SharePoint Foundation 2013 is the premiere web-based collaboration and productivity enhancement tool on the market today. With SharePoint 2013 Foundation, you can quickly access and manage documents and information anytime, anywhere though a Web browser in a secure and user friendly way. SharePoint hosting services start at only at €9.99/mo, allowing you to take advantage of the robust feature set for a small business price. HostForLIFE.eu offers a variety of hosted SharePoint Foundation 2013 plans as well as dedicated SharePoint 2013 Foundation options.