Articles about European Sharepoint Hosting Service
Posts tagged Hosting cheap european sharepoint server 2010 hosting

SharePoint 2013 Hosting – HostForLIFE :: Add, Update And Remove Web Part Using CSOM
May 5th
Introduction
Web parts are the building blocks of the pages by which you can modify the content, appearance and behavior of pages of a SharePoint site.
In this blog we are going to discuss how to Add, Update and Remove the web part using csom. Here I have used Content Editor Web Part in Wiki page.
Adding the web part in a wikipage
Step 1
First set the credentials by providing the user credentials.
Step 2
Using the client context, load the web.
Step 3
Get the object of the file using server relative url of the wiki page in which you want to add the web part. Example (/sites/Team Site/Site Pages/wikiPage.aspx).
Step 4
Get the ‘limitedWebPartManager‘ by using object file.
Step 5
Design the Xml string for importing the web part as definition of web part in ‘limitedWebPartManager’. In xml I have added the Title of web part as ‘My Web Part’.
Step 6
Then add the web part order and left zone of the page.
Follow the below code snippet,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
<span class="keyword">using</span> System; <span class="keyword">using</span> Microsoft.SharePoint.Client; <span class="keyword">using</span> Microsoft.SharePoint.Client.WebParts; <span class="keyword">using</span> System.Security; <span class="keyword">namespace</span> webpartadd { <span class="keyword">class</span> Program { <span class="keyword">static</span> <span class="keyword">void</span> Main(<span class="keyword">string</span>[] args) { <span class="keyword">string</span> userName = <span class="string">"userName@tenantName.onmicrosoft.com"</span>; <span class="keyword">string</span> password = <span class="string">"PassWord"</span>; <span class="keyword">string</span> siteUrl = <span class="string">"https://tenantName.sharepoint.com/sites/TeamSite"</span>; SecureString securePassword = <span class="keyword">new</span> SecureString(); <span class="keyword">foreach</span>(<span class="keyword">char</span> c <span class="keyword">in</span> password) { securePassword.AppendChar(c); } var credentials = <span class="keyword">new</span> SharePointOnlineCredentials(userName, securePassword); <span class="keyword">using</span>(ClientContext clientContext = <span class="keyword">new</span> ClientContext(siteUrl)) { <span class="keyword">try</span> { clientContext.Credentials = credentials; clientContext.Load(clientContext.Web); clientContext.ExecuteQuery(); File oFile = clientContext.Web.GetFileByServerRelativeUrl(<span class="string">"/sites/TeamSite/SitePages/wikiPage.aspx"</span>); LimitedWebPartManager limitedWebPartManager = oFile.GetLimitedWebPartManager(PersonalizationScope.Shared); <span class="keyword">string</span> xmlWebPart = <span class="string">"<?xml version=\"1.0\" encoding=\"utf-8\"?>"</span> + <span class="string">"<WebPart xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""</span> + <span class="string">" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\""</span> + <span class="string">" xmlns=\"http://schemas.microsoft.com/WebPart/v2\">"</span> + <span class="string">"<Title>My Web Part</Title><FrameType>Default</FrameType>"</span> + <span class="string">"<Description>Use for formatted text, tables, and images.</Description>"</span> + <span class="string">"<IsIncluded>true</IsIncluded><ZoneID></ZoneID><PartOrder>0</PartOrder>"</span> + <span class="string">"<FrameState>Normal</FrameState><Height /><Width /><AllowRemove>true</AllowRemove>"</span> + <span class="string">"<AllowZoneChange>true</AllowZoneChange><AllowMinimize>true</AllowMinimize>"</span> + <span class="string">"<AllowConnect>true</AllowConnect><AllowEdit>true</AllowEdit>"</span> + <span class="string">"<AllowHide>true</AllowHide><IsVisible>true</IsVisible><DetailLink /><HelpLink />"</span> + <span class="string">"<HelpMode>Modeless</HelpMode><Dir>Default</Dir><PartImageSmall />"</span> + <span class="string">"<MissingAssembly>Cannot import this Web Part.</MissingAssembly>"</span> + <span class="string">"<PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge><IsIncludedFilter />"</span> + <span class="string">"<Assembly>Microsoft.SharePoint, Version=13.0.0.0, Culture=neutral, "</span> + <span class="string">"PublicKeyToken=94de0004b6e3fcc5</Assembly>"</span> + <span class="string">"<TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>"</span> + <span class="string">"<ContentLink xmlns=\"http://schemas.microsoft.com/WebPart/v2/ContentEditor\" />"</span> + <span class="string">"<Content xmlns=\"http://schemas.microsoft.com/WebPart/v2/ContentEditor\">"</span> + <span class="string">"<![CDATA[This is a first paragraph!<DIV> </DIV>And this is a second paragraph.]]></Content>"</span> + <span class="string">"<PartStorage xmlns=\"http://schemas.microsoft.com/WebPart/v2/ContentEditor\" /></WebPart>"</span>; WebPartDefinition oWebPartDefinition = limitedWebPartManager.ImportWebPart(xmlWebPart); limitedWebPartManager.AddWebPart(oWebPartDefinition.WebPart, <span class="string">"Left"</span>, 1); clientContext.ExecuteQuery(); } <span class="keyword">catch</span> (Exception e) { Console.WriteLine(e); } } Console.WriteLine(<span class="string">"Succcesfully added webpart"</span>); } } } |
In the below image webpat is added in a wikipage,
Updating the web part in a wikipage
Step 1
First set the credentials by providing the user credentials.
Step 2
Using the client context, load the web.
Step 3
Get the object of the file using the server relative URL of the wiki page in which you want to add the web part. Example (/sites/team Site/Site Pages/wikiPage.aspx).
Step 4
Get the ‘limitedWebPartManager‘ by using object file.
Step 5
Load the web part using LINQ query expression to return only the title of each Web Part.
Step 6
Check the page having at least one web part for updating.
Step 7
Get the web part definition by using the order value.
Step 8
Change the web part Title then save the web part by calling ‘SaveWebPartChanges()‘.
Follow the below code snippet,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
<span class="keyword">using</span> System; <span class="keyword">using</span> Microsoft.SharePoint.Client; <span class="keyword">using</span> Microsoft.SharePoint.Client.WebParts; <span class="keyword">using</span> System.Security; <span class="keyword">namespace</span> UpdateWebpart { <span class="keyword">class</span> Program { <span class="keyword">static</span> <span class="keyword">void</span> Main(<span class="keyword">string</span>[] args) { <span class="keyword">string</span> userName = <span class="string">"userName@tenantName.onmicrosoft.com"</span>; <span class="keyword">string</span> password = <span class="string">"PassWord"</span>; <span class="keyword">string</span> siteUrl = <span class="string">"https://tenantName.sharepoint.com/sites/TeamSite"</span>; SecureString securePassword = <span class="keyword">new</span> SecureString(); <span class="keyword">foreach</span>(<span class="keyword">char</span> c <span class="keyword">in</span> password) { securePassword.AppendChar(c); } var cred = <span class="keyword">new</span> SharePointOnlineCredentials(userName, securePassword); <span class="keyword">using</span>(ClientContext clientContext = <span class="keyword">new</span> ClientContext(siteUrl)) { <span class="keyword">try</span> { clientContext.Credentials = cred; clientContext.Load(clientContext.Web); clientContext.ExecuteQuery(); File oFile = clientContext.Web.GetFileByServerRelativeUrl(<span class="string">"/sites/TeamSite/SitePages/wikiPage.aspx"</span>); LimitedWebPartManager limitedWebPartManager = oFile.GetLimitedWebPartManager(PersonalizationScope.Shared); clientContext.Load(limitedWebPartManager.WebParts, wps => wps.Include(wp => wp.WebPart.Title)); clientContext.ExecuteQuery(); <span class="keyword">if</span> (limitedWebPartManager.WebParts.Count == 0) { <span class="keyword">throw</span> <span class="keyword">new</span> Exception(<span class="string">"No Web Parts on this page."</span>); } WebPartDefinition oWebPartDef = limitedWebPartManager.WebParts[0]; WebPart oWebPart = oWebPartDef.WebPart; oWebPart.Title = <span class="string">"New WebPart Title"</span>; oWebPartDef.SaveWebPartChanges(); clientContext.ExecuteQuery(); } <span class="keyword">catch</span> (Exception e) { Console.WriteLine(e); } } Console.WriteLine(<span class="string">"Succcesfully updated webpart"</span>); } } } |
In the below image web pat title is update in a wikipage,
Removing the web part from a wikipage
Step 1
First set the credentials by providing the user credentials.
Step 2
Using the client context and, load the web.
Step 3
Get the object of the file using server relative URL of the wiki page in which you want to add the web part. Example (/sites/team Site/Site Pages/wikiPage.aspx).
Step 4
Get the ‘limitedWebPartManager‘ by using object file.
Step 5
Load the web part.
Step 6
Check the page having at least one web part for deleting.
Step 7
Get the web part definition by using the order value.
Step 8
Delete the web part by calling ‘DeleteWebPart ()‘.
Follow the below code snippet,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
using System; using Microsoft.SharePoint.Client; using Microsoft.SharePoint.Client.WebParts; using System.Security; namespace RemoveWebpart { class Program { static void Main(string[] args) { string userName = "userName@tenantName.onmicrosoft.com"; string password = "PassWord"; string siteUrl = "https://tenantName.sharepoint.com/sites/TeamSite"; SecureString securePassword = new SecureString(); foreach(char c in password) { securePassword.AppendChar(c); } var cred = new SharePointOnlineCredentials(userName, securePassword); using(ClientContext clientContext = new ClientContext(siteUrl)) { try { clientContext.Credentials = cred; clientContext.Load(clientContext.Web); clientContext.ExecuteQuery(); File oFile = clientContext.Web.GetFileByServerRelativeUrl("/sites/TeamSite/SitePages/wikiPage.aspx"); LimitedWebPartManager ltdWebPartManager = oFile.GetLimitedWebPartManager(PersonalizationScope.Shared); clientContext.Load(ltdWebPartManager.WebParts); clientContext.ExecuteQuery(); if (ltdWebPartManager.WebParts.Count == 0) { throw new Exception("No Web Parts to delete."); } WebPartDefinition webPartDef = ltdWebPartManager.WebParts[0]; webPartDef.DeleteWebPart(); clientContext.ExecuteQuery(); } catch (Exception e) { Console.WriteLine(e); } Console.WriteLine("Succcesfully deleted webpart"); } } } } |
In the below image web pat is deleted from the wikipage,

SharePoint 2013 Hosting – HostForLIFE :: Add, Get And Delete Quick Launch Navigation Using C#
Apr 30th
In this blog, we have discussed adding, retrieving, and deleting the SharePoint online quick launch navigation menu using the C# Server Object model. Follow the below coding to get the result.
Add new term in the quick launch
Add the below code in your Program.cs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
namespace GetNavigationNode { class Program { static void Main(string[] args) { string userName = "user1@tenantname.onmicrosoft.com"; string password = "********"; string siteUrl = "https:// tenantname.sharepoint.com/sites/AssociateSite"; SecureString securePassword = new SecureString(); foreach(char c in password) { secure Password.AppendChar(c); } var credentials = new SharePointOnlineCredentials(userName, securePassword); using(ClientContext clientContext = new ClientContext(siteUrl)) { client Context.Credentials = credentials; Navigation NodeCollection qlNavNodeColl = clientContext.Web.Navigation.QuickLaunch; client Context.Load(clientContext.Web); clientContext.Load(qlNavNodeColl); clientContext.ExecuteQuery(); NavigationNodeCreationInformation newNode = new NavigationNodeCreationInformation(); newNode.Title = "Search"; newNode.Url = "https://www.google.com"; qlNavNodeColl.Add(newNode); clientContext.ExecuteQuery(); } } } } |
After running the code,
Get Navigation node
Add the below code to get all the term from quicklunch.
1 2 3 4 5 6 7 8 9 10 11 |
using(ClientContext clientContext = new ClientContext(siteUrl)) { clientContext.Credentials = credentials; NavigationNodeCollection qlNavNodeColl = clientContext.Web.Navigation.QuickLaunch; clientContext.Load(clientContext.Web); clientContext.Load(qlNavNodeColl); clientContext.ExecuteQuery(); foreach(NavigationNode navToDelete in qlNavNodeColl) { var navNodeTitle = navToDelete.Title; Console.WriteLine("Navigation Node is : " + navNodeTitle); } } |

Delete Navigation Node
Add below code to remove the quick launch term
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
string userName = "user1@tenantname.onmicrosoft.com"; string password = "********"; string siteUrl = "https:// tenantname.sharepoint.com/sites/AssociateSite"; SecureString securePassword = new SecureString(); foreach(char c in password) { securePassword.AppendChar(c); } var credentials = new SharePointOnlineCredentials(userName, securePassword); using(ClientContext clientContext = new ClientContext(siteUrl)) { clientContext.Credentials = credentials; NavigationNodeCollection qlNavNodeColl = clientContext.Web.Navigation.QuickLaunch; clientContext.Load(clientContext.Web); clientContext.Load(qlNavNodeColl); clientContext.ExecuteQuery(); foreach(NavigationNode navToDelete in qlNavNodeColl) { var title = navToDelete.Title; if (title == "Search") { navToDelete.DeleteObject(); clientContext.ExecuteQuery(); } } } } |
After running the code,
From the above example of the code, we can conclude that, the CRUD operation of a quick launch navigation node in SharePoint Online using c# is very effective as it reduces the amount of time. You can also use this code for SharePoint 2019 and 2016.

SharePoint 2013 Hosting – HostForLIFE :: Highcharts Using SharePoint Online custom Lists
Apr 22nd
Hi there, in this blog you will learn about building HighCharts using SharePoint online lists using JavaScript REST API dynamically in 3 simple steps.
Step 1 – Get SharePoint list items using REST API GET Method
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
function getItems() { $.ajax({ url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('LeaveTracker')/items?$top=500&$select=Status", type: "GET", headers: { accept: "application/json;odata=verbose", }, success: function (data) { var items = data.d.results; for (var i = 0; i < items.length; i++) { var statusVar = items[i].Status; statusArray.push(statusVar); } fnDataArray();//Get Unique Status Count & Dataset for HighChart buildhighcharts();// Build Bar Chart }, error: function (error) { console.log(error); }, }); } |
Step 2 – Create Dataset for Highchart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
function fnDataArray() { var StatusObj = statusArray.reduce(function (count, status) { if (typeof count[status] == "undefined") { count[status] = 1; } else { count[status] += 1; } return count; }, {}); console.log(StatusObj); //Object Output -> {Open: 1, InProgress: 2, Completed: 1} //Get the values from our object var DataName = Object.keys(StatusObj); var DataCount = Object.values(StatusObj); ObjProperty = Object.getOwnPropertyNames(StatusObj); for (var i = 0; i < ObjProperty.length; i++) { DataSet.push({ name: DataName[i], data: [DataCount[i]], }); } } |
Step 3 – Build HighChart Bar Chart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
function buildhighcharts() { if (ObjProperty.length > 0) { $("#BarChart").highcharts({ credits: { enabled: false, }, chart: { type: "column", }, title: { text: null, }, xAxis: { visible: false, }, yAxis: { min: 0, title: { text: "No. of Requests", }, }, tooltip: { formatter: function () { return this.series.name + " : " + this.y; }, }, plotOptions: { column: {}, }, series: DataSet, //Data for chart }); } else { $("#BarChart").highcharts({ title: { text: "No data to display!", }, }); } } |
Screenshot
SharePoint 2013 Hosting – HostForLIFE :: Run Workflow For All Items Of List In SharePoint
Apr 15th
In some scenarios, we might need to develop workflows for the existing SharePoint list which has several list items. This happens because of some enhancements or user(s) requirements. Normally, we develop a workflow for lists or libraries, and workflow can execute manually, item add or update automatically.
Note
workflow means SharePoint workflow which is developed via SharePoint designer.
However, in some cases, we need to run workflow all items in List which is very panicked work via SharePoint GUI. We must select each list item and run workflow manually which is not effective or feasible in case there are too many items in a list. Additionally, it is a time-consuming task to run a workflow for each item.
Here, I am sharing a small piece of code in PowerShell command through which we can accomplish this requirement but note this will not start those workflows instantly. However, it can take up-to 5 minutes as it is triggered through SharePoint Timer Service. (use SharePoint PowerShell)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
$webApp = Get-SPWebApplication "http://sharepointUrl/sites/sitename" # URL of the Site $web = Get-SPWeb -Identity "http://sharepointUrl/sites/sitename" $workflowmanager = $web.Site.WorkFlowManager # Name of the list $list = $web.Lists["List Name"] # Name of the Workflow $assocname = $list.WorkflowAssociations.GetAssociationByName("On Item Created","en-US") $data = $assocname.AssociationData $items = $list.Items foreach($item in $items) { $workflow = $workflowmanager.StartWorkFlow($item,$assocname,$data,$true) } $workflowmanager.Dispose() $web.Dispose() |
After running this PowerShell script, the workflow will be triggered for each item in the mentioned list. This small Powershell script saves huge time compared to when we manually to run the workflows.

SharePoint 2013 Hosting – HostForLIFE :: Create A Folder And Set Unique Permission Using PnP PowerShell
Apr 5th
In this blog, we are going to create a folder in Document Library and set unique permission to a user for this created folder using PnP Power Shell. The Administrator can set the required permission to a user depending on the organizational needs. Here we can use this script to set permission to a particular user. Please follow the below steps.
Step 1
Run the ISE in administrative mode. Then declare variables named “sUrl”, “user”, “Folder Name”, and “SiteRelativeURL” to store the respective values.
Step 2
Connect to PnP online and get the credentials.
Connect-PnPOnline-Url$sUrl-Credentials (Get-Credential)
Step 3
To create the folder in the document, use the PnP commands as shown in the code.
Add-PnPFolder-Name$FolderName-Folder$SiteRelativeURL-ErrorActionStop
Step 4
Copy and run the below codes to create a folder in Document and to set unique permission in the folder for a user.
After running the script,

SharePoint 2013 Hosting – HostForLIFE :: Restore List From Existing In Modern SharePoint Online
Mar 25th
Recently, we have observed that the save the list as a template option is missing for the Modern SharePoint Online site. Because of which many users are getting confused about how to restore their existing list to another site which is mostly required and quite normal in terms of SharePoint. Save as s template was a very handy option to copy list definition as well as to migrate its contents in some cases.
Modern SharePoint Online is missing save as a template option for the SharePoint list.
We restore existing lists or libraries for various reasons,
- To restore existing list(s) into another site collection because of similar requirements for restoring list definitions
- Sometimes, we create development and production site collection. We create several lists and libraries on the development site and then after the completion of the development task, we again retore those lists and libraries into production.
- Sometimes, we retore the list in the same site collection with a different name to reuse the existing list and modify or use it as it is for another requirement.
- In some cases, we might need to restore into another tenant as well if we are working with a third-party or vendor for development or some purposes.
- In some cases, we use this option to migrate list or libraries contents
This is one of the general requirements to restore the existing list and library. Since the missing save as a template option is missing in modern SharePoint, we have some alternative ways to accomplish the same restoring of the list.
In this article, I will show you the different ways of restoring the list from existing in Modern SharePoint. So far, I have found 3 alternative ways
- Option 1: Create a new list from an existing list
- Option 2: By using PnP, save a modern list as a template and restore
- Option 3: By enable custom script in SharePoint Online
Create a new list from the Existing list
This option is quite fast, easy, user friendly, and most recommended where you can create a new list from the exiting option from another site collection.
Firstly, we need to create a new list from Site contents as shown
Open Destination Site collection -> Site Contents -> Click New -> Select List
Next, we will choose an option from the existing list as shown,
After selecting, from the existing list, you will get the option to choose site collection and list within that site collection as depicted,
Select the Site collection from which you want to restore the list and the list. Then you will get the option to add the list in the current site collection as demonstrated,
You can give a name, description, and option to show in site navigation as like creating a new list.
This is how you can restore the existing list template.
However, this option has some limitations which are listed below,
- Some lists might not be compatible which has lookup columns
- You cannot restore data
- Some legacy lists cannot be restored
- Some site collections are showing incompatible lists.
By using PowerShell, Save a modern list as a template
Using PowerShell, we can save a list as the template in modern sites both in team and communication sites including list definition and data.
For this option, you need to have PnP PowerShell installed on your pc. You need to run following PowerShell.
Explanation
First, we are defining siteUrl, listName (a list which we want to save as a template), templateName, and path variables with values.
Then connect to SharePoint online.
1 |
Connect-PnPOnline -Url $siteURL |
At last, we are extracting list and data with these commands,
1 2 3 |
Get-PnPProvisioningTemplate -Handlers Lists -ListsToExtract $listName -Out ("{0}.xml" -f $templateName) Add-PnPDataRowsToProvisioningTemplate -path ("{0}.xml" -f $templateName) -List $listName -Query '<view></view>' |
Additionally, we can add filters in data query.
Now, we have saved the list as a template. The second step is to add the template into the destination site collection.
We can achieve this by running this PowerShell.
1 2 3 4 5 6 7 8 9 10 |
$siteURL = " https://YourSite/sites/SiteCollectionName2" $templateName = "listTemplate" $path = “C:\Users\rijwa\Documents” cd $path Connect-PnPOnline -Url $siteURL Apply-PnPProvisioningTemplate -Path ("{0}.xml" -f $templateName |
This execution of command takes few minutes depending upon your list data.
After this, if we create a new list, we find this template in our site collection and we can restore the list.
By enabling custom script in SharePoint Online
Another option (not recommended) is by enabling custom scripts through SharePoint Admin Centre or PowerShell.
You can login to SharePoint Admin Centre -> Setting -> classic setting page.
Additionally, we can enable the specific site collection using the below PowerShell script.
1 2 3 4 5 6 7 8 9 |
#Variables for SharePoint Admin Center & Site Collection URL $AdminCenterURL = "https://site-admin.sharepoint.com/" $SiteURL="https://site.sharepoint.com/Sites/marketing" #Connect to SharePoint Online Connect-SPOService -url $AdminCenterURL -Credential (Get-Credential) #Disable DenyAddAndCustomizePages Flag Set-SPOSite $SiteURL -DenyAddAndCustomizePages $False |
Note
To apply the changes for enabling custom scripting might take up to 24 hours.
After enabling the custom script, we will need to go to list settings, and in the above URL, just replace listedit.aspx with savetmpl.aspx manually to save the list as a template.