3 Ways to Check in Documents in SharePoint

Are you trying to check in your document in SharePoint online documents?

One crucial aspect of document management in SharePoint is checking in documents. Whether you’re working with SharePoint Online or on-premises, understanding how to check in your documents properly is essential for maintaining version control and ensuring seamless collaboration.

This guide will walk you through the steps and best practices to successfully check in your document in SharePoint, making your document management more efficient and collaborative.

What is a Checked-In Document?

The term check-in describes the process of adding new or modified files, items, and pages to a document library to replace the previous version.

A checked-in document in SharePoint refers to a document that is no longer in an editable or exclusive state, allowing multiple users to access and collaborate on it simultaneously.

📝 Note: Your modifications will not be visible to other SharePoint users until you check in the document. This includes both changes to the document body and changes to document properties. This frequently leads to misunderstanding because you see all the changes, but your coworkers do not.

Understanding what a checked-in document is and how it functions is vital for effective document management within SharePoint. In the following session, you will delve into the process of checking in documents in SharePoint and explore best practices to ensure a smooth and collaborative document management experience.

Check-In Document from Document Library

To check-in document in SharePoint online, follow these steps:

  1. Login to your office 365 account
  2. Click on App launcher at the top left corner of your page.
  3. Click on SharePoint.

This will take you to SharePoint Home page. Select the team site containing the documents you want to check in.

  1. Click on Document. This will take you to the document library.
  2. Present inside the document library, click on the folder where the documents you want to check in are located.

This will display all the documents present in the selected folder earlier.

📝 Note: To check in document(s) in SharePoint, the document(s) must have initially been checked out. This means that a document must be checked out for various reasons before it can be checked back in.

The document to check in have a tiny outward-pointing red arrow in the document icon.

📒 Read More: Check out this post to learn How to check out documents in SharePoint.

  1. Click on the document you want to check in. This will display a panel.
  2. Click on More on the display panel.
  3. Click on Check in.

After clicking on check in, a dialog box will appear.

  1. In the Check In dialog box, you can enter a comment such as what you changed or added in the document.
  2. Click on Check In.

This will successfully check in the documents. Notice that the tiny outward-pointing red arrow in the document icon will disappear. Also, you’ll get a notification pop up on the screen showing the document that was checked In. This means that anyone can now open and edit the file again at the same time.

Always make sure you save changes on the document before checking in. Since SharePoint leaves the document checked out and nobody else can edit, discard the check out if you don’t want changes made.

You can check document changes in version history. To do so:

  1. Select the file you checked in.
  2. click on the three dots beside the file.
  3. Click on Version history.

This will display the version history of the checked in file. In there, you will see the comment you made when checking in the document. The version history helps in tracking changes for effective collaboration.

Check-In Document using PowerShell Script

PowerShell allows you to automate and simplify various tasks, including checking in documents, making it an efficient choice for users who prefer command-line interfaces.

With PowerShell, you can check in multiple documents simultaneously, making it a time-saving solution for those handling large sets of files or managing documents programmatically.

Whether you’re an IT professional, a developer, or simply looking for a streamlined approach, this method can be a valuable addition to your toolkit.

Follow these steps to check-in documents in SharePoint Online using PowerShell Script.

Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
  1. Open your PowerShell and Load SharePoint CSOM assemblies. This is necessary to interact with SharePoint online. Click enter on your keyboard afterward.
Function Checkin-Document($SiteURL, $FileRelativeURL, $Credentials)
{
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Credentials

    Try {
        #Try to get the File from URL
        $File = $Ctx.web.GetFileByServerRelativeUrl($FileRelativeURL)
        $Ctx.Load($File)
        $Ctx.ExecuteQuery()

        #check if the file is checked out
        If($File.CheckOutType -eq "None")
        {
            write-host "Document is not checked out Already!" -f Red
            break
        }
        #Checkin the document
        $File.CheckIn([string]::Empty,[Microsoft.SharePoint.Client.CheckinType]::MajorCheckIn)
        #Checkin Types: MajorCheckIn,MinorCheckIn,OverwriteCheckIn

        $Ctx.ExecuteQuery()

        write-host "Document has been checked-in successfully!" -f Green
    }
    Catch {
        write-host -f Red "Error checking-in Document!" $_.Exception.Message
    }
}
  1. Define the function. The created PowerShell function Checkin-Document is used to check in a document. This function takes three parameters:
  • $SiteURL: The URL of the SharePoint site.
  • $FileRelativeURL: The relative URL of the document to check out.
  • $Credentials: The credentials for connecting to SharePoint Online.

This establishes a connection to SharePoint Online, checks if the document is checked out, and then checks it in.

$SiteURL= "https://your-sharepoint-site-url"
$FileRelativeURL= "/sites/YourSite/Shared%20Documents/YourDocument.docx"

# Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
  1. Next, you can replace https://your-sharepoint-site-url/, /sites/YourSite/YourLibrary/YourDocument.docx, your-username, and your-password with the appropriate values for your SharePoint Online environment.
Checkin-Document -SiteURL $SiteURL -FileRelativeURL $FileRelativeURL -Credentials $Cred
  1. You’ll call Checkin-Document function with the defined parameters to check in the document.

This PowerShell script will successfully check in the selected document used in the script. It is important to input all the parameters correctly so as not to run into PowerShell errors while running the commands.

In some cases, you might need to check in documents from their Item ID rather than using the document URL. To do this, you can use the following PowerShell script to check in a document based on its Item ID:

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
   
#Set Variables for Site URL, Library Name and Item ID
$SiteURL= "https://your-sharepoint-site-url/"
$LibraryName="Documents"
$ItemID="4"
 
#Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
 
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Cred
 
#Get the web, List, Item adn File
$Web=$Ctx.Web
$List=$web.Lists.GetByTitle($LibraryName)
$Item=$list.GetItemById($ItemID)
$File=$Item.File
 
#Get the File to context
$Ctx.Load($File)
$Ctx.ExecuteQuery()
         
#determine if sharepoint document is checked out
If($File.CheckOutType -eq "None")
{
    write-host "Document is not checked out Already!" -f Red
}
else
{
    #Check in the file: sharepoint online force check in powershell
    $File.CheckIn("Checked-in from PowerShell",[Microsoft.SharePoint.Client.CheckinType]::MajorCheckIn)
    $Ctx.ExecuteQuery()
     
    write-host "Document has been checked-in successfully!" -f Green

This script will successfully check in your selected document in SharePoint.

Also, if you need to check in many files at once in SharePoint Online:

📝 Note: You need to have SharePoint Online Management Shell installed on your computer.

Here is the PowerShell command to check in multiple files in the SharePoint Online document library:

# Load SharePoint Online PowerShell Module
if ((Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable).Count -eq 0) {
    Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Force -AllowClobber
}
  1. Open your PowerShell script and add the following lines to load the necessary SharePoint Client Assemblies. These assemblies should be installed when you install the SharePoint Online Management Shell. This is necessary to interact with SharePoint online. Click enter on your keyboard afterward.
# Set default parameters
$SiteURL = "https://your-sharepoint-site-url"
$LibraryName = "Documents"
  1. Define the parameters you need for the script. Replace https://your-sharepoint-site-url with the SharePoint site URL and replace the Documents with the library where you want to perform bulk check-ins.
# Connect to SharePoint Online and authenticate
$Cred = Get-Credential
Connect-SPOService -Url $SiteURL -Credential $Cred
  1. Next run the script, this script prompts you to enter your SharePoint Online credentials. Once entered, it connects to your SharePoint site and authenticates your session.
# Prepare the query to retrieve all files
$Query = "<View Scope='RecursiveAll'>
    <Query>
        <OrderBy><FieldRef Name='ID' Ascending='TRUE'/></OrderBy>
    </Query>
    <RowLimit Paged='TRUE'>2000</RowLimit>
</View>"

# Loop through and check in files
$Counter = 1
Do {
    $ListItems = Get-SPOListItem -List $LibraryName -Query $Query

    # Get all checked out files
    ForEach ($Item in $ListItems | Where-Object { $_.FileSystemObjectType -eq "File" }) {
        # Display progress
        Write-Progress -Activity "Scanning Files in the Library" -Status "Checking if the file is Checked-Out '$($Item.FieldValues.FileLeafRef)' ($Counter of $($ListItems.Count))" -PercentComplete (($Counter / $ListItems.Count) * 100)

        $File = Get-SPOFile -Web $SiteURL -List $LibraryName -File $Item.FieldValues.FileLeafRef
        $CheckedOutByUser = $File.CheckedOutByUser

        if ($File.Level -eq "Checkout") {
            Write-Host -ForegroundColor Yellow "Found a Checked out File '$($File.Name)' at $($SiteURL)$($Item.FieldValues.FileRef), Checked Out By: $($CheckedOutByUser.LoginName)"
            $File.CheckIn("Checked-in By Administrator through PowerShell!", [Microsoft.SharePoint.Client.CheckinType]::MajorCheckIn)
            Write-Host -ForegroundColor Green "File '$($File.Name)' Checked-In Successfully!"
        }
        $Counter++
    }
} while ($ListItems.ListItemCollectionPosition -ne $null)
  1. The script prepares a query to retrieve all files from the specified library. It then iterates through the files, checking if any of them are checked out. If a file is checked out, it is checked in with a comment.

PnP PowerShell can also be used to check in documents. Here is how to use PnP PowerShell to check in all documents in the SharePoint Online document library:

# Prepare the query to retrieve all files
$Query = "<View Scope='RecursiveAll'>
    <Query>
        <OrderBy><FieldRef Name='ID' Ascending='TRUE'/></OrderBy>
    </Query>
    <RowLimit Paged='TRUE'>2000</RowLimit>
</View>"

# Loop through and check in files
$Counter = 1
Do {
    $ListItems = Get-SPOListItem -List $LibraryName -Query $Query

    # Get all checked out files
    ForEach ($Item in $ListItems | Where-Object { $_.FileSystemObjectType -eq "File" }) {
        # Display progress
        Write-Progress -Activity "Scanning Files in the Library" -Status "Checking if the file is Checked-Out '$($Item.FieldValues.FileLeafRef)' ($Counter of $($ListItems.Count))" -PercentComplete (($Counter / $ListItems.Count) * 100)

        $File = Get-SPOFile -Web $SiteURL -List $LibraryName -File $Item.FieldValues.FileLeafRef
        $CheckedOutByUser = $File.CheckedOutByUser

        if ($File.Level -eq "Checkout") {
            Write-Host -ForegroundColor Yellow "Found a Checked out File '$($File.Name)' at $($SiteURL)$($Item.FieldValues.FileRef), Checked Out By: $($CheckedOutByUser.LoginName)"
            $File.CheckIn("Checked-in By Administrator through PowerShell!", [Microsoft.SharePoint.Client.CheckinType]::MajorCheckIn)
            Write-Host -ForegroundColor Green "File '$($File.Name)' Checked-In Successfully!"
        }
        $Counter++
    }
} while ($ListItems.ListItemCollectionPosition -ne $null)

With these PowerShell scripts, you can easily perform bulk check-ins of files in your SharePoint Online library. This automation can save you time and streamline your document management process within SharePoint Online.

Check-In Wiki Pages

In SharePoint, wiki pages are a versatile tool for creating and sharing information within your organization.

These pages are dynamic and can be edited collaboratively, but there are scenarios where you may need to ensure that only one person can edit a wiki page at a time. This is where the document checkout feature comes in handy.

Follow these steps to check in the wiki page:

  1. Enter your desired SharePoint site where you have your checked-out wiki page.
  2. Click on Site Contents at the bottom left corner of your page.
  3. Scroll down and click on the Site Pages at the bottom.

This will display all the wiki pages present on that site. Locate the page to check in. This page has a tiny outward-pointing red arrow document icon.

  1. Click on the wiki page you want to check in. This will display a panel.
  2. Click on More on the display panel.
  3. Click on check in.

After clicking on check in, a dialog box will appear.

  1. In the Check In dialog box, you can enter a comment such as what you changed or added in the wiki page.
  2. Click on Check In.

This will successfully check in the wiki page. Just like a checked in document, notice that the tiny outward-pointing red arrow in the page icon will disappear. Also, you’ll get a notification pop-up on the screen showing the document that was checked In. This means that anyone can now open and edit the file again at the same time.

Always make sure you save changes on the wiki page before checking in. Since SharePoint leaves the document checked out and nobody else can edit, discard the check out if you don’t want changes made.

Conclusions

Mastering the process of checking in documents and wiki pages in SharePoint is vital for efficient document management and collaboration.

Whether using the user interface in SharePoint Online or PowerShell scripts for automation, understanding the outlined steps empowers users to maintain version control seamlessly. The guide covers both user-friendly and automated approaches, highlighting the versatility of PowerShell for bulk operations.

Emphasizing the importance of version control, the guide ensures users can navigate these processes effectively for a streamlined document management experience in SharePoint.

About the Author

Durojaye Olusegun

Durojaye Olusegun

Durojaye is a cybersecurity professional and data analyst with a knack for distilling complex technical information into simple, digestible guides. His diverse skill set not only covers the intricate world of cybersecurity but also delves into the realm of Microsoft 365 tools. Whether he's crafting informative blog posts or engaging social media content, or staying updated on the latest trends in his field, Durojaye always brings a unique perspective to his work.

Related Articles

Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Get the Latest Tech Tips

Write For Us

Are you a tech enthusiast with a talent for writing great content? Come write for us!

Follow Us

Follow us on social media to stay up to date with the latest in tech!