Scenario
In one of the our SharePoint online projects, my colleague created the list called “TestList” in which the URL of the list becomes “/Lists/TestList/AllItems.aspx.” Our customer had given us the excel sheet and we need to import the excel content in the list. Excel content was imported successfully and around 600 items were added into the list. Everything is OK now. Only thing is that the URL of the list is “TestList” and not the proper list. My colleague created it with the intention of testing.
Now a simple approach to have a proper list URL is to create a new list with the proper URL. Import the excel again to the list and we are done. Here this is possible because we only need to create list and import excel but in some cases like where workflows are associated and executed or there were item level permissions then it becomes a tedious and time consuming task.
Solution
So we were wondering if rather than doing all the steps again is there any way where we can change the URL of the list directly so we don't need to create a new list and import excel again?
First thought that came to mind is “List Settings;” we went to list settings but couldn't find any way to change the URL of the list. As shown below in the “General Settings” of the list,
Figure 1 : List General Settings
Only possible option is to change the List name, description and navigation but not the URL.
The next thought that came was of PowerShell and it is possible to change the URL of the list with PowerShell command?
We need to move the RootFolder of the list to new URL, following is the small PowerShell script to change the URL of the list in SharePoint online.
- #Web url where is the list exist, of which we need to change the URL
- $url = ""
-
- $userName ="" # Your site user name
- $password ="" # Password
-
- # convert password into secured string
- $securedpw = ConvertTo-SecureString $password -AsPlainText -Force
-
- #Creating instance of client context
- [Microsoft.SharePoint.Client.ClientContext]$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($url)
-
- $clientContext.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $securedpw)
-
- #Fetching the list
- $web = $clientContext.Web
- $lists = $web.Lists
- $clientContext.Load($web)
- $clientContext.Load($lists)
- $clientContext.ExecuteQuery()
-
- $list =$lists.GetByTitle("TestList") # TestList is also the title of list which we want to change
- $clientContext.Load($list)
-
- $Context.ExecuteQuery()
-
- #Fetching the RootFolder of the list
- $rootfolder = $list.RootFolder
-
- #Move the root folder to new URL
- $rootfolder.MoveTo("NewURL") # NewURL - new url of the list
-
- $Context.ExecuteQuery()
There is one more alternative to change the URL of the list using the SharePoint designer.
- Open the SharePoint designer.
- Go to “All Files” option as shown in below fig 2,
Figure 2 : SharePoint Designer - All Files
- Go to the list in which we need to change the URL
- Right click on it and Rename as
Figure 3 : SharePoint Designer - Renaming the list
- Once list is renamed it changes the URL.
Thanks!
Enjoy Reading :)
As usual any feedback / query / suggestions are most welcome !!!
Read more articles on SharePoint:
- Task Management In SharePoint (On-Prim/Online) - Part Four
- SharePoint 2013: Promoted Search Results