Register Remote Event Receivers on the HOST web

The project that I’m working on requires that I add remote event receivers to the host web for my Provider-hosted app. This is a little unusual – most of the stuff I found about remote event receivers was using the app web. It turns out, though, that it is possible, and there is a good explanation of how it works by Johnny Tordgeman on CodeProject. Rather than repeat all he’s said, I suggest you take a look. I just want to expand on some of the things I learnt doing this, that he didn’t mention. Continue reading “Register Remote Event Receivers on the HOST web”

Advertisement
Register Remote Event Receivers on the HOST web

App Deployment Error: "Your app handles the uninstalling app event"

When trying to do an F5-Deploy of a Provider hosted app from Visual Studio, I got this error during the deployment:

Error occurred in deployment step ‘Uninstall app for SharePoint’: Your app handles the uninstalling app event. Ensure that the Windows Azure Cloud Web Service project is deployed to the emulator prior to uninstalling the app.

This happened just after the step “Uninstall app for SharePoint” in the process. Continue reading “App Deployment Error: "Your app handles the uninstalling app event"”

App Deployment Error: "Your app handles the uninstalling app event"

Handle your Provider Hosted SharePoint App 'App Installed' event

I’m creating a Provider-hosted app, and I want to do some things when the app is installed/uninstalled. It isn’t immediately obvious how you set that up in VS2012. Continue reading “Handle your Provider Hosted SharePoint App 'App Installed' event”

Handle your Provider Hosted SharePoint App 'App Installed' event

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