Fail: Visual Studio 'Verify' for Office 365 in 2010 compatibility mode

Right, so I’m trying to develop some Remote Event Receivers. I’ve been using our company’s tenant. Lets call it https://mytenant.sharepoint.com. That tenant was a SP2010 one, which has been upgraded.

I am trying to test using https://mytenant.sharepoint.com/sites/AWBTest. It’s a SP2013 site collection. Unfortunately, https://mytenant.sharepoint.com is still running in 2010 mode. Continue reading “Fail: Visual Studio 'Verify' for Office 365 in 2010 compatibility mode” →

Fail: Visual Studio 'Verify' for Office 365 in 2010 compatibility mode

Adding Custom Actions to SharePoint using CSOM

So I’ve been working with Office 365, and deploying site collections and their contents can be … fun. I’ve found that the best approach seems to be to use the Client-side Object Model (CSOM) – the C# API – to deploy and configure my content.

On thing I didn’t think would be easy was adding Custom Actions – but this turned out to be pretty easy, to be honest. Continue reading “Adding Custom Actions to SharePoint using CSOM” →

Adding Custom Actions to SharePoint using CSOM

Setting Taxonomy and URL fields in JavaScript Form Templates

Recently, I’ve had a need to build a custom New and Edit form in an Office 365 system. Often I’d approach this with a little custom Application page to use as the form, but that isn’t available in Office 365. I had been about to start writing reams of JQuery and JavaScript until one of my colleagues introduced me to JSLinks. Continue reading “Setting Taxonomy and URL fields in JavaScript Form Templates” →

Setting Taxonomy and URL fields in JavaScript Form Templates

Using JSOM to query SharePoint 2013 lists with Taxonomy Fields

So, I’d an interesting problem. I have a SharePoint 2013 list that uses a Managed Metadata (or ‘Taxonomy’) field. I need to, through the JavaScript Client Object Model, get all items that have a particular value or a child of that value on the taxonomy tree. As an example, here’s my taxonomy:termSet Sounds like it should be simple to query this, right? Well, not so much. Continue reading “Using JSOM to query SharePoint 2013 lists with Taxonomy Fields” →

Using JSOM to query SharePoint 2013 lists with Taxonomy Fields

Looking up against Large Lists in Office 365

So, I had an issue that I’ve a customer who wanted to have some items look up against a large list. (In fact, it was a large document library). This large list had more than 5000 items. This is a little unfortunate, due to a painful and annoying quirk in SharePoint’s design. Continue reading “Looking up against Large Lists in Office 365” →

Looking up against Large Lists in Office 365

O365: Uncheck the Overwrite checkbox

We have a customer who are planning on putting a lot of documents into a Library in SharePoint. These documents will be uploaded, by hand, and are nearly always the ‘final’ version of the document. Given the number of documents in the library, the plan is to find them again using their metadata, which seems like a good idea.

However, there’s a catch – what if someone has uploaded a document with that filename already? Continue reading “O365: Uncheck the Overwrite checkbox” →

O365: Uncheck the Overwrite checkbox

Visual Studio always upgrade my solution

I’m upgrading a Visual Studio 2010 solution to a Visual Studio 2012 one. It’s part of a migration of a solution from SharePoint 2010 to 2013 (and there are good details about this here). Annoyingly, though, every time I open the project it says that it has ben upgraded and shows an Upgrade Report. Nothing appears to be modified, but still, it’s shown.

Google didn’t show a lot of help on this, but in the end I decided to simply open the .csproj file and look for some sort of flag about being upgraded. I found the element:

<FileUpgradeFlags>0</FileUpgradeFlags>

so I tried deleting the ‘0’ and reloading the project – and it didn’t show an Upgrade Report. Hurrah. Not sure why I needed to so this, though.

Visual Studio always upgrade my solution

Issues with getting the SP.ClientContext in SharePoint 2013

So, I’m migrating a solution from SP2010 to 2013. In the JavaScript for part of the solution, I use the JavaScript client-side object model (JSOM). This involves getting the current ClientContext for the site:

var clientContext = new SP.ClientContext.get_current();

Unfortunately, ClientContext was null, so I kept getting Null Reference exceptions.

“Weird”, I thought, “This worked in 2010”. Now, my solution has a very similar piece of code elsewhere in it, so I went and tested it – and it worked. Even weirder.

Next up, I tried using a SP.SOD.executeOrDelayUntilScriptLoaded() call around the code where I got the ClientContext. Surely it was just a matter of waiting for the JavaScript file ‘sp.js’ to load? Well, it never loaded. With these two lines…

SP.SOD.executeOrDelayUntilScriptLoaded(function () { alert('SP.Runtme.js Loaded'); }, 'SP.Runtime.js');
SP.SOD.executeOrDelayUntilScriptLoaded(function () { alert('SP.js Loaded'); }, 'SP.js');

…no alerts were shown. On the page that works, they both get shown nearly instantly.

Okay, so it’s not my code then, it’s that the JSOM isn’t initializing, but only on one particular page. That sucks. What can I do to initialise it? Well, I found this post describing the same problem, but for publishing pages. Mine isn’t – it’s an application page – but I suspected it might be the same issue. And I checked MSDN which describes initialising sp.js.

I added this line:

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function () { });

And my code began working again on this page. So it seems that for some pages in SharePoint 2013 the Client Object Model isn’t necessarily initialized.

Issues with getting the SP.ClientContext in SharePoint 2013