Check the ClientId/ClientSecret of your App

I have had a problem today that a provider hosted app that I’ve been working on would deploy and work in an F5-Debug deployment, but when I tried to do a proper deployment, well, it wouldn’t work. I already thought I knew what I needed to change between an F5 and a proper deployment – so what was wrong? Continue reading “Check the ClientId/ClientSecret of your App”

Check the ClientId/ClientSecret of your App

Getting App Errors from Office 365 with PowerShell

When you’re developing apps sometimes you’ll have errors occur. How do you get any kind of log entry about that?

Well, it turns out help is at hand – there is a PowerShell command Get-SPOAppErrors. This gets you the app errors for a particular App ID. For example:

Connect-SPOService -Url https://example-admin.sharepoint.com
Get-SPOAppErrors -ProductId DEADBEEF-CAFE-BABE-FACE-BEADEDFACADE | Select-Object -first 5 | fl

This will get the first 5 entries for the app with the given GUID and output their details on the PowerShell command window.

Getting App Errors from Office 365 with PowerShell

Sending Email from Azure with SendGrid

In SharePoint Online I need to send email(s) when a user updates a document. Who this email goes to involves some fairly complex logic – which we’ll ignore for this post. So how do we send the email? SharePoint Online doesn’t allow you to use SPUtility.SendEmail() or System.Net.Mail.SmtpClient – so unless you’re using standard alerts, or the workflow “Send Email” activity, well, you’re going to have to look elsewhere. I didn’t think SharePoint designer Workflows were quite up to the complexity of it, so I started to look elsewhere – at Remote Event Receivers, provider-hosted in Azure.

This leads to the question “can Azure send email?” I can imagine a few reasons why it maybe shouldn’t (think “spam”). Continue reading “Sending Email from Azure with SendGrid”

Sending Email from Azure with SendGrid

Debug and Publish modes when deploying SharePoint Apps

Recently I’ve been working with a provider hosted SharePoint App. The objective of the app is to register a remote event receiver on a library in the host web, and then handle events from it. There’s a good article about this on CodeProject, and as usual, Chris O’Brien has been there and blogged about this too.

Anyway, working on my app I had a number of problems around deploying it, both for debug and ‘live’, in particular around the AppManifest.xml file. Continue reading “Debug and Publish modes when deploying SharePoint Apps”

Debug and Publish modes when deploying SharePoint Apps

Column Indexing Oddities in SharePoint

I’ve come across a few issues lately with list column indices (indexes?) in SharePoint that have caused some trouble recently.

  • Multi-valued columns cannot be indexed. It doesn’t matter what type they are, they can’t be indexed. This isn’t actually so surprising when you think about it – where in the index would they be – though it might be nice if they simply appeared in it twice. To be honest, I’d known this for some time, but it did catch me out recently.
  • Lookup Columns can’t be used in ListViews set up through the UI. It seems that the SharePoint UI sets the list view up to filter using the ‘text’ of the column, which isn’t indexed – rather than using the LookupId, which is. A List View in a list definition, or set up through code, can therefore be fine…
  • The Approval Status column added by Content Approval can’t be indexed.
  • Single-valued Managed Metadata (Taxonomy) columns can be indexed – but not sorted. ORDER BY clauses won’t work (more on how to solve that in a later post). I think this is due to multi-lingual support – but it is a pain.

Yes, some of these issues are particularly acute given some of Office 365’s search limitations, and awkwardness with Content Approval.

Column Indexing Oddities in SharePoint

Connect to Office 365 with CSOM

If you’re going to connect to SharePoint Online 2013 in Office 365, you’ll need to reference a few assemblies in your solution:

  • Microsoft.SharePoint.Client
  • Microsoft.SharePoint.Client.Runtime
  • System.Security

You’ll find these in the SharePoint Server 2013 Client Components SDK if you’ve not got them already.

In your code you’ll then need to create a ClientContext for your connection, including creating a SharePointOnlineCredentials object, and then you can start to talk to your SharePoint instance.

string url = "https://example.sharepoint.com/sites/testsite";
string username = "Office365User@example.com";
string userpass = "password";
using (ClientContext clientContext = new ClientContext(url))
{
	Console.WriteLine("Connecting to {0} as {1}", url, username);
	SecureString passWord = new SecureString();
	foreach (char c in userpass.ToCharArray()) passWord.AppendChar(c);
	clientContext.Credentials = new SharePointOnlineCredentials(username, passWord);
	Web web = clientContext.Web;
	clientContext.Load(web);
	clientContext.ExecuteQuery();
	Console.WriteLine("Got Web {0}", web.Url);
}

And this will be the basis of my future examples of doing things in Office 365 SharePoint using CSOM.

Connect to Office 365 with CSOM

Powershell in Office 365 … and why you need CSOM

Edit: It seems Chris O’Brien has been thinking about the same problem, and has a good post about it.

Microsoft claim that Office 365 has PowerShell support. I had assumed that this meant that most, or at least many, of the PowerShell commands I can use in a normal farm would also be available in Office 365.

I was wildly, spectacularly wrong. Continue reading “Powershell in Office 365 … and why you need CSOM”

Powershell in Office 365 … and why you need CSOM

"Minor" Search limitations in Office 365

If you’re a SharePoint developer like me, you probably find the Query Throttle in SharePoint an absolute pain. This is a feature where, under an unnecessarily complicated set of conditions, if you try to ask for too many list items in one query, SharePoint refuses.

Now, while I understand why such a limit is necessary – albeit I’d rather it was simpler – it is something of a problem. For example, multi-choice columns cannot be indexed. If you want to query such a column, and there are more than 5000 items in the list, we’ll, you’re outta luck.

That situation is surprisingly common in Document Management systems. Continue reading “"Minor" Search limitations in Office 365”

"Minor" Search limitations in Office 365