Articles about European Sharepoint Hosting Service
Posts tagged Spain Sharepoint 2013 Hosting
SharePoint 2013 Hosting – HostForLIFE :: Migrate documents and folders from old SharePoint servers to New SharePoint using .Net CSOM
May 17th
As we all know, SharePoint has been evolving since 2001 from its initial release to SharePoint online and now the SharePoint Subscription edition. Every organization that has been using SharePoint for years also has/had to upgrade its version. You can upgrade or migrate the content from the old version to the newer version of SharePoint in various ways.
As we all know, SharePoint has been evolving since 2001 from its initial release to SharePoint online and now the SharePoint Subscription edition. Every organization that has been using SharePoint for years also has/had to upgrade its version. You can upgrade or migrate the content from the old version to the newer version of SharePoint in various ways.
Problem
I came across a problem of migrating folders and files from the SharePoint 2010 version to the SharePoint Subscription edition (successor of SharePoint 2019).
My requirement was simple: migrate around 0.5 million files and folders from one specific site on SP 2010 to a specific site on SPSE, retaining author and timestamps as is.
Solution
Of course, there are plenty of tools available in the market which can migrate from any old version to any new version of SharePoint. Still, it comes at the cost of thousands of dollars, which I think no one wants to spend, especially when you are a core developer.
So the first free tool that came into my mind was SharePoint Migration Tool (SPMT), but when I explored it in detail, I found out that it supports migration from on-premise versions to only SharePoint Online.
The second thought that came to mind was about site backup restore, taking site backup using a PowerShell command and restoring it to a new server. But this will not work because of the database version mismatch.
The third solution I thought about was – the database upgrade approach, taking a backup of the whole database from SQL Server 2008 R2 and restoring it on SQL Server 2019. But again, this won’t work as Microsoft recommends upgrading your databases from 2010 to 2013 to 2016 and then 2019 – that’s a very hectic process and needs many server versions to be installed on different machines.
Final solution
So, the last option left was to build my tool to migrate the folders and files from one server to another.
Prerequisites to make this solution works,
- Have the latest version of Visual Studio installed on a machine from which you can access both old and new Sharepoint sites. I am using VS 2019.
- Ensure the account you are using to run the tool has at least contributed access to both the source and destination site.
- Ensure you have installed “SharePoint Online Client Components SDK” on your machine.
- Make sure all the users who have access to the old Sharepoint site are already granted access to the new SharePoint site – this is a must-do step before migration. Without this, Authors and editors won’t get copied as is.
Approach of migration
- If you have huge content at the source site, then plan to migrate it to multiple destination sites and have separate content databases for each site.
- We will migrate the content site-wise and then library wise
- Migrate all folders first
- Then migrate all the files
- Identify a service account at the new SharePoint server, which can be used to replace the authors/editors who are not part of the organization anymore. This is required. Otherwise, the author and editor will appear as blank as those users are no more available in the active directory.
Build the tool
We are going to create a simple console application. You can make it fancier by creating forms applications and building a nice UI. It’s up to you.
Finally, here is the C# CSOM code; First, get all the folders migrated, and then migrate all the files.
Function to migrate the folders
Function to migrate the files
Error handling
If in case the tool fails for some reason, we know at which item it has failed. Observe the error, fix it at the code level, change the query with the last item ID, which was migrated successfully, and run again.
Summary
Thanks for reading! It takes hardly a few hours to build your tool to migrate the content, and in today’s world of ChatGPT, it become easier to find the exact code chunk. So don’t fall into the trap of paid tools and save the cost to your organization. I hope this will help you guys.
Problem
I came across a problem of migrating folders and files from the SharePoint 2010 version to the SharePoint Subscription edition (successor of SharePoint 2019).
My requirement was simple: migrate around 0.5 million files and folders from one specific site on SP 2010 to a specific site on SPSE, retaining author and timestamps as is.
Solution
Of course, there are plenty of tools available in the market which can migrate from any old version to any new version of SharePoint. Still, it comes at the cost of thousands of dollars, which I think no one wants to spend, especially when you are a core developer.
So the first free tool that came into my mind was SharePoint Migration Tool (SPMT), but when I explored it in detail, I found out that it supports migration from on-premise versions to only SharePoint Online.
The second thought that came to mind was about site backup restore, taking site backup using a PowerShell command and restoring it to a new server. But this will not work because of the database version mismatch.
The third solution I thought about was – the database upgrade approach, taking a backup of the whole database from SQL Server 2008 R2 and restoring it on SQL Server 2019. But again, this won’t work as Microsoft recommends upgrading your databases from 2010 to 2013 to 2016 and then 2019 – that’s a very hectic process and needs many server versions to be installed on different machines.
Final solution
So, the last option left was to build my tool to migrate the folders and files from one server to another.
Prerequisites to make this solution works,
- Have the latest version of Visual Studio installed on a machine from which you can access both old and new Sharepoint sites. I am using VS 2019.
- Ensure the account you are using to run the tool has at least contributed access to both the source and destination site.
- Ensure you have installed “SharePoint Online Client Components SDK” on your machine.
- Make sure all the users who have access to the old Sharepoint site are already granted access to the new SharePoint site – this is a must-do step before migration. Without this, Authors and editors won’t get copied as is.
Approach of migration
- If you have huge content at the source site, then plan to migrate it to multiple destination sites and have separate content databases for each site.
- We will migrate the content site-wise and then library wise
- Migrate all folders first
- Then migrate all the files
- Identify a service account at the new SharePoint server, which can be used to replace the authors/editors who are not part of the organization anymore. This is required. Otherwise, the author and editor will appear as blank as those users are no more available in the active directory.
Build the tool
We are going to create a simple console application. You can make it fancier by creating forms applications and building a nice UI. It’s up to you.
Finally, here is the C# CSOM code; First, get all the folders migrated, and then migrate all the files.
Function to migrate the folders
Function to migrate the files
Error handling
If in case the tool fails for some reason, we know at which item it has failed. Observe the error, fix it at the code level, change the query with the last item ID, which was migrated successfully, and run again.
Thanks for reading! It takes hardly a few hours to build your tool to migrate the content, and in today’s world of ChatGPT, it become easier to find the exact code chunk. So don’t fall into the trap of paid tools and save the cost to your organization. I hope this will help you guys.

SharePoint 2013 Hosting – HostForLIFE :: Call to Action Web Part in SharePoint Online
May 11th
In this blog, we will understand the use of the Call to Action web part. The “Call to Action” web part in SharePoint Online is a feature that allows you to create visually compelling and attention-grabbing content on your site’s pages. The web part can be used to promote specific actions or messages to your site visitors, such as signing up for a newsletter, downloading a document, or filling out a form.
Adding Call to Action web part to SharePoint online page
- To include a Call to Action web part on a SharePoint Online page, access the page’s Edit mode by clicking the Edit button located in the upper-right corner of the page, select the plus “+” icon to add a new web part, search for the Call to Action web part in the search box, and choose the Call to Action web part.
- Once you have inserted the Call to Action web part to your SharePoint Online page, the default layout will be automatically displayed in the page, and you will be presented with editing options such as Move, Edit, Duplicate, and Delete Web Part. Additionally, you will have the option to zoom in or out, as well as set the focal point for any background images you have chosen to use. Enter the required text in the “Add your call to action text here” field. When creating a call to action, keep the text length in mind to avoid truncation.
- On click of the Edit web part option, a property pane will appear on the right side of the screen, which will include a variety of formatting options such as:
- Background Image: The background image feature in the Call to Action web part of SharePoint Online enables users to add an engaging visual element to the web part. To set the background image for the Call to Action web part in SharePoint Online, click on Change and select the desired image source from the new pane, which may include options to select the image from SharePoint files, upload from your computer, and more. Once you have selected the image, click Open to apply it as the background.
- Button Label: This option allows you to customize the text that is displayed on the button, giving you the ability to create a more personalized and effective call to action.
- Button Link: This option allows you to specify the destination URL that the button will link to when clicked by the user. When specifying the button link, it is important to ensure that the URL start with http, https, or mailto, and that it directs the user to the intended destination. Additionally, when a user hovers over the button, the URL will be displayed, giving them a preview of where the link will take them.
- Alignment: This option allows to change the alignment of both text and button to right, center or left. Left alignment is the default selected alignment.
The Call to Action Web part in SharePoint Online helps to provide a clear and compelling message to encourage visitors to take action, such as subscribing to a newsletter or filling out a form.

SharePoint 2013 Hosting – HostForLIFE :: SharePoint Online Management Shell V16.0 Assembly Error Fix
Apr 18th
Issue
I was recently required to use SharePoint Management shell to run some O365 PowerShell commands. But as soon as I run the SharePoint Management shell in administrative mode, I received the below error:
Could not load type ‘Microsoft.SharePoint.Client.Publishing.PortalLaunch.PortalLaunchRedirectionType’ from assembly ‘Microsoft.SharePoint.Client.Publishing, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’.
I have gone through many links that tell me to uninstall the assembly and reinstall, but I didn’t find the exact step-by-step guide. So, I am writing this blog to provide a step-by-step guide in case someone else might face such an issue.
Resolution
The reason for this error is conflicts between different versions of Sharepoint Online SDKs (SharePoint Client Components, SharePoint Online Management Shell). So correct way to solve this problem is the following:
- Go to Control Panel > Programs and Features and uninstall all instances of SharePoint Online Management Shell and SharePoint Client Components
- Open the PowerShell console and uninstall existing versions of Microsoft.Online.SharePoint.PowerShell module:
- After that, close PowerShell, open a new session and install the latest version of Microsoft.Online.SharePoint.PowerShell module:
Install the SharePoint Online Management Shell latest version from the below link:
https://www.microsoft.com/en-in/download/details.aspx?id=35588
When you start the SharePoint Online Management Shell as administrator, you will not face the error.

SharePoint 2013 Hosting – HostForLIFE :: How To Create Access Token From SharePoint Online?
Apr 13th
How To Create Access Tokens From SharePoint Online?
An access key token is used to authenticate your access to Microsoft translator API. It provides secure access to Microsoft Translator API.
Here we can set up OAuth for SharePoint Online to authorize REST API calls to the SharePoint site to retrieve and manipulate the site data.
Step 1
Register an app in SharePoint.
Step 2
Navigate to https://your_site_name.com/_layouts/15/appregnew.aspx
Step 3
Click Generate for Client Id and Client Secret.
Step 4
It will ask to fill in Client Id, Client Secret, Title, App Domain, and Redirect URI.
- Client Id is a GUID for the SharePoint Add, which we got while registering the App.
- Client Secret- it is the password for the add-ins. It is associated with the client id; it will be shown again. We need to store it securely or be able to regenerate a new client secret.
- Title- You can fill in any name, which is used to display in the add-in trust screen.
- App Domain- The host of the remote server of the add-in. If the https is not configured in 443, we need to mention the port number.
- Redirect URI- The endpoint of the remote application to send the ACS authentication code.
Note. The Client’s secret key validity is one year since the creation of your Apps. We will use Powershell to update the key.
Step 5
Generate a new ClientSecret for this clientID. It uses the same clientId as set in the above step. The new ClientSecret is valid for 3 years.
1 2 3 4 5 6 7 8 9 10 11 |
$bytes = New-Object Byte[] 32 $rand = [System.Security.Cryptography.RandomNumberGenerator]::Create() $rand.GetBytes($bytes) $rand.Dispose() $newClientSecret = [System.Convert]::ToBase64String($bytes) $dtStart = [System.DateTime]::Now $dtEnd = $dtStart.AddYears(3) New-MsolServicePrincipalCredential -AppPrincipalId $clientId -Type Symmetric -Usage Sign -Value $newClientSecret -StartDate $dtStart -EndDate $dtEnd New-MsolServicePrincipalCredential -AppPrincipalId $clientId -Type Symmetric -Usage Verify -Value $newClientSecret -StartDate $dtStart -EndDate $dtEnd New-MsolServicePrincipalCredential -AppPrincipalId $clientId -Type Password -Usage Verify -Value $newClientSecret -StartDate $dtStart -EndDate $dtEnd $newClientSecret |
Step 6
Copy the output of $newClientSecret.
Step 7
Replace the Web.config with this ClientId and ClientSecret. You don’t need SecondaryClientSecret app settings.
Step 8
Wait at least 24 hours to propagate ClientSecret to SharePoint Office (SPO)
Create a Package for your Client
Step 1
Open SharePoint Online.
Step 2
Put the URL ” https://your_site_name.com/_layouts/15/appregnew.aspx “.
Fill in the details,
After that, you have to click Create a button to get a confirmation screen.
Here are the steps for creating the Access key token in SharePoint online and extending the Client secret using the Powershell command.

SharePoint 2013 Hosting – HostForLIFE :: Image Gallery Web Part in SharePoint Online
Apr 6th
Image Gallery Web Part in SharePoint Online
This blog post provides a comprehensive guide on using the Image Gallery Web part in SharePoint Online. With the Image gallery web part, you can showcase multiple images in a collection with a title at the top for better organization and visual appeal using various layouts such as Brick, Grid, and Carousel.
Adding Image Gallery Web part in SharePoint Online Page
Step 1. To insert the Image Gallery web part into your Site Page, switch to edit mode by selecting “Edit” on the top right, click on the circled “+” icon, and select the Image Gallery web part from the list of available options.
Step 2. Image Gallery Web Part will be inserted under with default layout along with editing options such as Move, Edit, Duplicate, and Delete web part. To open the property pane, click on the Edit web part option.
Step 3. Click on Add Images to insert images. This will open the following default options. Select the appropriate option, insert the images, and add the title at the top if required.
Step 4. On click of Edit web part, the property pane on the right side of the screen will be displayed containing the following options.
- Image Options- Select the appropriate option from Select Images and Dynamically display images from a document library (Images can be selected from either Documents or Site Assets).
- Include subfolders- To insert subfolders, if any.
- A maximum number of images to display 255 images can be inserted.
Step 5. Layouts
The image Gallery web part includes three layouts: Grid, Brick, and Carousel.
Grid Layout
In this layout, the caption and title can only be viewed when the image is open in full size. This layout also has the option to change the Aspect Ratio of the Images.
Brick Layout
The SharePoint Image gallery web part allows users to rearrange images in a Grid layout and view titles and captions only when images are viewed in full size.
Carousel Layout
The Carousel layout in the SharePoint Image gallery web part displays captions and titles below the image; it does not allow for re-ordering of images but enables users to navigate through images using arrows or automatic rotation at set intervals.
Step 6. Editing the Image
Click on the image inserted in the Image Gallery. The property pane with options to edit images will be displayed on the right side of the screen. These options can be used to change the image’s title, Add a caption to the selected image, or Add Alternative Text to the image.
This is how we can use the Image Gallery Web part in SharePoint Online.
SharePoint 2013 Hosting – HostForLIFE :: SPFx Webpart Ignoring Target Attribute In Anchor Tag
Mar 30th
Every modern page in SharePoint, by default, uses a page router(smart navigation) when a hyperlink is clicked to navigate. This behavior is intentional to avoid a complete refresh of the screen.
During development using SPFx( SharePoint Framework), smart navigation behavior might not be the expected one in all cases, as one of its consequences is using the target
attribute to open a page in a separate tab in the browser will be ignored.
Consider the following valid HTML markup, which will work outside SPFx:
Valid HTML
In the above case, the target
attribute will be ignored, and the page opens in the same tab via page router logic. To override the page router for hyperlinks, add the data-interception
attribute to the link with a value of off as shown below
.
HTML that would work in SPFx
When the link is clicked in the above example, the page will open in a new tab.
Have a nice day!!