SharePoint page showing BLANK

I have an Office 365 site collection that I’ve been provisioning from within PowerShell – and automatically uploading webparts.   I’m getting some weird behaviour though :


When looking at VIEW SOURCE – it’s even stranger – that’s the ENTIRE page !


Even when looking at the page request/s via FIDDLER – nothing seemed off.   And nothing in the console or error log in the F12 developer tools.

I could view the page with the ?contents=1 appended to the URL – but still no answer.


I worked out that it’s actually a SEARCH webpart that is causing the issue – but I couldn’t work out WHY…

This was my PowerShell code to upload the webpart to the page – some other O365 guff around this – but this is the basic code (using CSOM) :

$wpm = $pubFile.GetLimitedWebPartManager([Microsoft.SharePoint.Client.WebParts.PersonalizationScope]::Shared);       
$wpcoll = $wpm.WebParts

$webPartFileContents = [System.IO.File]::ReadAllText($filepath);
$wpd = $wpm.ImportWebPart($webPartFileContents);

$wpdNew = $wpm.AddWebPart($wpd.WebPart, $xmlwp.ZoneID, $webPartCount);

Within the .WEBPART file, there’s the usual XML bits & pieces – and a bunch of properties.


After lots of blog post hunting – off/on for a few days actually – and re-building the WebPart contents piece-by-piece, I noticed it was breaking on properties like this >

<property name=”RenderTemplateId” type=”string”>~sitecollection/_catalogs/masterpage/Display Templates/Search/Control_SearchResults.js</property>

It was THIS post from Chris O’Brien that made me hunt down this path :

..but then the page does not load (blank screen, HTML not output properly) and ULS shows the following runtime error:

Application error when access /SitePages/CSWP_Provisioned.aspx, Error=Cannot make a cache safe URL for “item_picture3lines_cob_provisioned.js”, file not found. Please verify that the file exists under the layouts directory.
at Microsoft.SharePoint.Utilities.SPUtility.MakeBrowserCacheSafeLayoutsUrl(String name, Boolean localizable, Int32 desiredVersion)   

I couldn’t check the log files – with Office 365 – but I think it’s the same issue.

My next thing to try was to change the markup within my .WEBPART – and I had success !


Changed to :


Just needed to change from ~ to the equivalent in encoding ~

I’m unsure exactly WHY this is occurring – perhaps the PowerShell upload is losing this and/or encoding it wrong – but it worked !

Hopefully that helps someone – or at least, this post is a reference for ME, if it ever happens AGAIN !

Office 365 send email using JavaScript (REST)

I have a fairly simple requirement for some JavaScript (jQuery) to send an email.   This is within the code for a SharePoint Online page (Office 365).

My initial thinking was to do a HTTP POST request to the Office 365 REST endpoint, but nothing could have prepared me for the next few hours of my day.

I had to jump through a few hoops, and perform backflips while juggling – and THEN changed tack entirely.   I thought I’d share my observations – and some sample code/link.

This was my starting point (MSDN) :    Send a new message on the fly (REST)

I wrangled with it for a few hours :

  • SharePoint hosted code (JS), calling to was resulting in a 401 – due to a X-Domain call.
  • HTTP POST with JSONP doesn’t work – only for GET
  • CORS is what was messing it up – 401’ing the request
  • Even trialling with the new – same problem
  • Suggestions via Twitter were to do an Azure AD app – TO SEND AN EMAIL !!
  • I even found one ridiculous solution that was to create workflow from Visual Studio or SharePoint Designer – and then CALL it from CSOM.    #WTF !!

A colleague mentioned “surely SharePoint has something to send an email” – it could then process the email traffic SERVER SIDE.   

That was an unholy yee-haar gold nugget of joy.

Posting from my jQuery back to SharePoint Online is a simple REST call.   And, it does NOT suffer from X-Domain or CORS.    


There’s a blog post that I found, with a great code sample – and it’s now working for me :

Sending email with SharePoint and jQuery

Just note that the recipient is limited to a valid SharePoint user for security reasons.    (within the same tenant)

So – it’s the simply “KISS” principle – keep it simple, stupid.   


Add to Office365 PropertyBag (PowerShell)

Been fiddling with some script to ADD a value to the PropertyBag for a SharePoint site within Office365.

There’s a great post (and script) on the Microsoft site – for READING all properties :

How to read all property bags in a SharePoint Online Site Collection

But, for adding a new key, I had to fiddle & find an answer.

This post also – mentions the issue with “persisting” values :

Add and Retrieve property bag by CSOM (thanks !!)

NB.   This code (PowerShell) will only ADD a key/value – if not already in place.    (You’ll need to change slightly – to UPDATE the value)

        $rootWeb = $spoCtx.Web

        $allProps = $rootWeb.AllProperties;

        # DOESN’T WORK !!
        # $allProps.FieldValues.Add(‘KEY’, $value);

        $rootWeb.AllProperties[‘KEY’] = $value;


That’s not TOO tricky in the end – just needed some fiddley syntax to make it work – especially the POWERSHELL bit…

Hope that helps you – it was a battle for me.   


Office 365 SharePoint Site Templates

When creating a new site collection within O365, you can choose the default (RootWeb) template to use.  

Most of these are the same as SharePoint2013 – but there are a few slight differences.


The easiest way to check the site template ‘name’ for use in PowerShell is actually to use the F12 developer tools – and view the HTML – neat trick !


For reference, I’ve made a list of all of them below.


  • STS#0 – Team Site
  • BLOG#0 – Blog
  • DEV#0 – Developer Site
  • PROJECTSITE#0 – Project Site
  • COMMUNITY#0 – Community Site


  • BDR#0 – Document Center
  • EDISC#0 – eDiscovery Center
  • OFFILE#1 – Records Center
  • EHS#1 – Team Site – SharePoint Online configuration
  • BICenterSite#0 – Business Intelligence Center
  • POLICYCTR#0 – Compliance Policy Center
  • SRCHCEN#0 – Enterprise Search Center
  • SPSMSITEHOST#0 – My Site Host
  • COMMUNITYPORTAL#0 – Community Portal
  • SRCHCENTERLITE#0 – Basic Search Center
  • visprus#0 – Visio Process Repository


  • BLANKINTERNETCONTAINER#0 – Publishing Portal
  • ENTERWIKI#0 – Enterprise Wiki

Hopefully that helps someone out there – it certainly made sense for me – as it was missing the CMSPUBLISHING#0 which is the normal SP2013 “Publishing” site.


SQL Azure, error when editing stored procs

I have a SQL Server database within my Azure tenant, but I’ve been unable to edit any Stored Procedures – or view the list of procs.

The message I get is “unknown property IsNativelyCompiled”.


There are procs in there – I can execute then, or see view via SP_HELPTEXT – but not within Enterprise Manager (Management Studio).

This is within SQL Server 2014 (Management Studio – just the client tools on my Win8.1 PC)


It turns out there’s a SP1 for SQL2014 – which also updates the client tools.

Refer to this blog, for the various SQL build versions.

Unfortunately, the SP1 has been pulled – doh.    (At time of writing).   

For now, I’ve installed SQL 2014 CU6 – which is 640MB !

I can now view the list of Stored Procedures – and edit/update – phew !

Simple AngularJS – getting started

With the buzz around AngularJS, I’ve kinda missed the boat on some of it – and getting started ‘late’.

Then again, I’m a ‘fashionably late’ kinda person – and that’s A-OK with me !


In order to get started, I thought I’d share some observations and ideas.

YES – it’s a big topic – and this first post is a ‘hello world’ style mini-app.

To get it working, just save the content to a separate file – one for the HTML and one for the JavaScript (app.js).

(1) The HTML

The following HTML is as basic as you can get – explanation below.

<!DOCTYPE html>
<html ng-app=”testApp”>
<body ng-controller=”testCtrl”>
<h3>{{ greeting }}</h3>

The main pieces are highlighted :

  • testApp is the name of the ‘program’ like and is a container holder, for the whole page
  • testCtrl is the name of the ‘controller’ which is the portion of the app, and used for the model/controller execution.

You’ll note that these have special Angular attributes >  ng-app and ng-controller.

There are also a few JavaScript references – for the AngularJS code (include) – and our code (app.js).

(2) The JavaScript

Again, to keep it simple, this is pretty much the only bits you need.

var app = angular.module(‘testApp‘, []);

app.controller(‘testCtrl‘, [‘$scope‘, function ($scope) {
$scope.greeting = “Hello friends !”;

This does the following logic :

  • Get a reference to the ‘program’ – ie. testApp – into a variable called ‘app’.
  • Use the ‘app’ variable and define the ‘controller’ – ie. testCtrl
  • Define a function to set the property (element) of ‘greeting’.

The key piece here is the thing called “$scope”.   This is a variable passed into the function – and thus you can do >  $scope.messageText.

This is because the value in HTML has {{braces}} around it.

Hope that’s enough to get a quick 101 jump start – the journey of a thousand miles begins with a single step…!


Here’s a cool sample that builds upon the above – with more fields :

SQL Azure Admin Password

When creating a brand-new SQL Azure Database, I was unsure on how to connect to it.

There is a button to “Show connection strings” – but that shows as :


Thee is the ability to open within Visual Studio (bottom row of buttons) – but it would then ask me to provide a password – but HOW/WHAT is it !!??!


It turns out that there is an easy way to do this.

If you consider that each DATABASE will live on a specific SERVER, you need to set the Administrator password for the ‘SERVER’ itself.

  • Click on the link for the ‘server’


  • Flip to the ‘Dashboard’ tab
  • There’s a link to ‘Reset Admin Password’


Obviously – you don’t want to do this for EVERY database – but if you’re doing it for the first time, then you need to SET the password.

P.S.  The default login account is :   AzureCloudAdmin

Too easy – in the end !

Invalid issuer or signature

I’ve been deploying a SharePoint app to a new farm (actually, it’s a different O365 tenant), and so I had to generate a new CLIENT ID and SECRET.

I’d updated this within the WEB.CONFIG of my provider hosted app – ASP.NET MVC running on Azure – and then published to my Azure WebSite.

BUT – I’m getting this error when using the app from SharePoint :

SecurityTokenException: Invalid issuer or signature.

It turns out that I’d forgotten to update the properies within Azure.   

Those settings in the WEB.CONFIG are for a localhost deployment – you need to use the “CONFIGURE” page for Azure.


Scroll down – and check that you’ve correctly set the (NEW) client id and secret.


Make sure to click “SAVE” – and then you should be A-OK to simply re-try the SharePoint app.

It would be nice if the exception message gave more details !     “check the ClientID and Secret” !   


Hopefully that helps someone !

The (very important) APP DOMAIN

SharePoint error : An error occurred while processing your request

I’ve just trying to get a Provider Hosted sample working – with a AZURE website – and an Office 365 App.   This has been an “all day” thing – not working !

I’d done all the steps – with the ClientId – and ClientSecret – and included in my WEB.CONFIG.

But – when accessing my App, I’d simply see a message :

An error occurred while processing your request

This is coming from the following code – within the ‘default.aspx’ for the website.

protected void Page_PreInit(object sender, EventArgs e)
    Uri redirectUrl;
    switch (SharePointContextProvider.CheckRedirectionStatus(Context, out redirectUrl))
        case RedirectionStatus.Ok:
        case RedirectionStatus.ShouldRedirect:
            Response.Redirect(redirectUrl.AbsoluteUri, endResponse: true);
        case RedirectionStatus.CanNotRedirect:
            Response.Write(“An error occurred while processing your request.“);

So – it was LOADING my site, but couldn’t display.

It turns out, that I’d been ‘faster-stepping’ through the wizard to assign the “CLIENT ID” and “CLIENT SECRET”.

If/when you’re using APPREGNEW.ASPX – make sure to put the correct Azure WebSite domain

As below – the APP DOMAIN is important – don’t just put ‘contoso’ or ‘localhost’.


It turns out, I’d been “super careful” on the CLIENT ID and CLIENT SECRET – but not paying much attention to the App-Domain.

Hope this helps – it woulda saved me a bunch-of-hours…!

SharePoint Search Results with DateTime field refiner

When configuring a SEARCH RESULTS page, you can include any of your own custom columns as ‘refiners’.   These show on the side of the results, allowing users to filter down the results.

When you choose a field as a refiner, the data shown will depend on the type of the field.      Eg.  TEXT fields, will just show as the item values


When using a DATE field – for some reason, there’s a nasty symptom that doesn’t show the values correctly !

This symptom was also highlighted and blogged by Simon Doy.

WHY ?    The field is showing as 2,012 and 2,013 ??

My refiner is doing the same thing – compared to the Out Of The Box Created field :



I’m happy to report that there’s a very simple fix – and it’s related to the NAME of the managed property you create.

In my example :

  • DON’T name the property as “STaRCreatedDateTime”
  • Instead – it should be “STaRCreatedDateTimeOWSDATE

There’s some SharePoint JavaScript code that looks for the ‘type’ of the field – within the tail of the field name.    Sure enough – it works !


Thanks to SIMON for the tips and investigation – his blog goes into a lot of depth, with a custom refiner to change the look/feel.

It was this tip that saved the day :


Thanks Eman !      (Credit where credit is due)