SharePoint Online

Copy SharePoint online webpart settings from one webpart to other

Here is the simple PowerShell script which does the magic to copy the webpart configurations from one webpart to other.

All you have to do is

  • Identify the source and target webpart. Here in below script we have two different pages source.aspx and target.aspx
  • In the source.aspx OOTB hero webpart added on the page.
  • On the target.aspx another OOTB hero webpart also added on the page
  • The script copies the setting of source.aspx hero webpart to target.aspx hero webpart
  • Let’s assume if you change any image on the source.aspx hero webpart and apply the same settings on the target.aspx hero webpart. This script is much useful when you run.
  • The important thing is to note is to convert the retrieved json format to object here is the line $convertedJson = ConvertFrom-Json $sourceWebpartData this is already included in the below script. This is important because when we retrieve the webpart properties json. The format is not json aligned. So we are converting it to json object.
#################################################################################################
#Set Webpart Properties using PnP
#################################################################################################
Connect-PnPOnline -url https://fivenumber.sharepoint.com/sites/spdev/ -UseWebLogin

$sourcePageName="source.aspx"
$targetpageName1="target.aspx"

$sourceWebpartTitle="Hero" # Your webpart name

$sourcePageInstance= Get-PnPClientSidePage -Identity $sourcePageName
$sourceWebpartInstance = $sourcePageInstance.Controls | ?{$_.Title -eq $sourceWebpartTitle}
$sourceWebpartData = $sourceWebpartInstance.PropertiesJson | ConvertTo-Json

#Write-Host($sourceWebpartData)
$convertedJson = ConvertFrom-Json $sourceWebpartData

Set-PnPPageWebPart -Page $targetpageName1 -Identity <your-target-webpart-id-goes here> -PropertiesJson $convertedJson

Server-side activities have been updated. You need to restart SharePoint Designer to use the updated version of activities.

If you come across error message Server-side activities have been updated. You need to restart SharePoint Designer to use the updated version of activities. while creating SharePoint workflow

Server-side activities have been updated. You need to restart SharePoint Designer to use the updated version of activities.

Server-side activities have been updated. You need to restart SharePoint Designer to use the updated version of activities.

 

You need to copy the file Microsoft.SharePoint.WorkflowServices.Activities.Proxy.dll to the location %USERPROFILE%\AppData\Local\Microsoft\WebsiteCache\<site-name>\<version-number>

Copy file to location

Copy file to location

 

Restart SharePoint designer, you should be able to create workflow without any problem.

Add Background Header To SharePoint Online Site

In this post, I am going to show you how to add header image as background to SharePoint online site, this will be very simple all we need is a image, and CSS class.

The beauty of the approach what we follow now is… we neither touch existing master page nor existing CSS

We will implement this by using an  alternate CSS approach So, let’s work out

I have two files, an image named as header.png and a custom CSS named as style.css this custom CSS has a single class referring the image as background.

Header image

Header image

Style.css

[sourcecode language=”css”]
#s4-titlerow
{
height: 176px;
background-image:url(‘/sites/Demo/Style%20Library/images/header.png’);
}
[/sourcecode]

Let’s upload the header.png under style library > images folder

Upload header image to style library > images folder

Upload header image to style library > images folder

Then after, upload the style.css file to style library > style folder (if you don’t see style by default, create one)

Upload style.css file to style library > style folder

Upload style.css file to style library > style folder

Now, the final step is to set the alternate css, grab the uploaded style.css link, the link will be like https://<your-sharepoint-online-domain>/sites/Demo/Style Library/style/style.css
Once you have the link, got to site gear > Site settings, under look and feel section, click on Master page
scroll down to the bottom of the page, expand Alternate CSS, the select the radio button to Specify a CSS file to be used by this site and all sites that inherit from it: provide the style.css location, then click OK

Updated Alternate CSS URL

Updated Alternate CSS URL

After you complete the all the steps, you will be able to see the header as below 🙂

SharePoint online custom header

SharePoint online custom header