Identify the latest version of SP Online

As SharePoint online rolls out every new feature every fortnight thought Microsoft’s global customer base, hence it is difficult to identify the current version of SP in the logged tenant.

Now, this app is developed intended to share the information about the SP version of the tenant.

Here is link to download the source code from GIT

Get SPO Version

Advertisements

App Secret Expiry Notification

Active Directory provides a beautiful feature as reminder before the expiry of a password.But, unfortunately, App ID & Secret being a modern Identity method, there is no way to get a notification for the same.Hence, this script is developed.

This script will send a consolidated summary mail with

1.App Name

2. Remaining days for client secret to expire and

3. URL where it is installed for every app having an expiry date on a given O365 tenant.

Here is the link for ready to use script.This can be configured on decided frequency on a need basis.

O365-App-Secret-Expiry

 

Identify SharePoint site template from HTML source

Identify SharePoint site template from HTML source

Open any SharePoint Site in any browser & open the HTML source for the same. Now search for

var g_wsaSiteTemplateId

And here you get the site temple, like

var g_wsaSiteTemplateId = ‘STS#0‘;

//This is for a team site.

Now to identify the actual site type for the template please refer this

https://social.technet.microsoft.com/wiki/contents/articles/11154.sharepoint-site-template-codes.aspx

Add Search Navigation Using CSOM in SPO

Below snippet helps to add search navigation to a site in SharePoint online

 

public static SecureString GetCredentials(string strPassword)
{SecureString Securepwd = new SecureString();

foreach (char c in strPassword.ToCharArray())

{Securepwd.AppendChar(c);}
return Securepwd;}

Microsoft.SharePoint.Client.ClientContext _context = new Microsoft.SharePoint.Client.ClientContext([SPO Site URL]);
_context.Credentials = new Microsoft.SharePoint.Client.SharePointOnlineCredentials([Username], GetCredentials([Credentials]));
Dictionary<string, string> dicsearchnavcollection = new Dictionary<string, string>();
dicsearchnavcollection.Add(“Search Navigation1 Title”, “Search Navigation1 URL”);//SP will automatically add “?k={query}”
dicsearchnavcollection.Add(“Search Navigation2 Title”, “Search Navigation2 URL”);
dicsearchnavcollection.Add(“Search Navigation3 Title”, “Search Navigation3 URL”);
dicsearchnavcollection.Add(“Search Navigation4 Title”, “Search Navigation4 URL”);
dicsearchnavcollection.Add(“Search Navigation5 Title”, “Search Navigation5 URL”);
Web web = _context.Web;
var nav = web.Navigation;
NavigationNode searchNav = nav.GetNodeById(1040);
NavigationNodeCollection nodeCollection = searchNav.Children;
NavigationNodeCreationInformation newnav = new NavigationNodeCreationInformation();
foreach (KeyValuePair<string, string> searchnav in dicsearchnavcollection.Reverse())
{
newnav.Url = searchnav.Value;
newnav.Title = searchnav.Key;
nodeCollection.Add(newnav);
}
_context.ExecuteQuery();

 

 

Set/Reset Masterpage in a SPO sites using JSOM

During development of master pages, in case the recently uploaded one has some wrong syntax, the site will not be accessible from UI due to conversion error of the master page.In such cases, the default master page can be reset using JSOM from browser console.

 

//Get the current site context
var context=new SP.ClientContext([URL]);
var web=context.get_web();
//Setting the default masterpage
var strMasterPageUrl = ‘/[server relative URL]/_catalogs/masterpage/seattle.master’;
web.set_customMasterUrl(strMasterPageUrl);
web.set_masterUrl(strMasterPageUrl);
web.update();
context.executeQueryAsync(function ()
{alert(‘Master Page has been set to ‘ + strMasterPageUrl);
}, function (sender, args) {
alert(‘Error: ‘ + args.get_message());
});

 

Create Sub Site in SPO Public Site

Here is a script to create a sub site in public site for a O365 subscription.

#Public site Url for the tenant.
$siteUrl=”[Public Site URL for your tenant]”
#User name for tenant admin or the site owner of the public web site
$username = “[username]”
#Password for the user
$password = Read-Host -Prompt “Enter password” -AsSecureString
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
$ctx.Credentials = $credentials
$webCreationInformation = New-Object Microsoft.SharePoint.Client.WebCreationInformation
#Basic inoformation
$webCreationInformation.Url = “[Sub site URL]”
$webCreationInformation.Title = “[Sub site Title]”
$webCreationInformation.WebTemplate = “STS#0”
$newWeb = $ctx.Web.Webs.Add($webCreationInformation)
$ctx.Load($newWeb)
$ctx.ExecuteQuery()

The SPListItem being updated was not retrieved with all taxonomy fields.

While doing a backup & restore below error flashed out while trying to add a Taxonomy value in field.

“The SPListItem being updated was not retrieved with all taxonomy fields.”

The reason is due to backup – restore one of the site property value named
taxonomyhiddenlist got copied from the source site.

There are 2 options to fix this error

A. Manually browsing through the site & using SharePoint designer.

The steps are

  1. Navigate to the URL as and go to list settings.

https://siteurl/Lists/TaxonomyHiddenList/

2. Capture the GUID of the list (exclude initial %7B or { and %7D or }, which may show differently in different browsers.)

taxonomylistguid.PNG

3. Open the site with designer an navigate to Site Options

designerfileribbon

and search for the property “taxonomyhiddenlist”

designersiteoptionswindow.PNG

and modify the value as highlighted above (7f2a129c-4919-4bd3-bb46-4e8792bc4358).Post this the changes apply and save the site from designer.

2. Using the below SharePoint Powershell as

$web=Get-SPWeb -Identity [SiteURL]
$taxonomyhiddenlist= $web.Lists[“taxonomyhiddenlist”]
$taxonomyhiddenlistGuid=$taxonomyhiddenlist.ID
$web.Properties[“taxonomyhiddenlist”]=$taxonomyhiddenlistGuid
$web.Update()
$web.AllProperties[“taxonomyhiddenlist”]
$web.Dispose()

The error should be resolved now.