SPFx solution using PnPjs for Project Online REST API

SPFx Project SharePoint

If you know me or follow me on Twitter/LinkedIn, you must have realized by now how much I like the PnPjs library. Enough to venture myself to speak about it on 3 SharePoint Saturday events last year. The library has packages for SharePoint and Graph endpoints and can be easily used on SPFx solutions. But if you need an SPFx solution that consumes Project Online API, what options do you have?
Kudos to Paweł Hawrylak who started creating the Project module for PnPjs and currently already offers support for a wide range of endpoints. The module is currently in a dev branch and requires additional work and testing, but it’s already a phenomenal effort.

This blog post will cover the required steps to generate a local PnPjs Project package to consume Project Online REST APIs and create an SPFx web part that uses it.

Continue reading “SPFx solution using PnPjs for Project Online REST API”

Restore deleted documents already restored by OneDrive

Imagine the following scenario:

  • A user syncs a SharePoint document library using OneDrive, so that he can have a local copy of the documents. 
  • When he doesn’t need them anymore, he deletes the documents from the machine (which is a sensible approach).
  • OneDrive syncs the changes and deletes the documents in the SharePoint library.
  • User notices that the documents were deleted, opens the recycle bin and restores them.
  • One Drive syncs all the documents back to the SharePoint library and all is good again. NOT!

Even though all your documents are back into the SharePoint document library, they do not contain information about previous versions. This information is recorded against the original list item object. The original documents, containing the version history information are now in the site recycle bin. But, because OneDrive uploaded a new copy of the documents, you are unable to restore the deleted versions. This is because the library already contains a document with the same name.
This is simple to manually resolve if you only have a few documents affected. But what if we are talking about hundreds or thousands? And multiple libraries? Well, in this case, PnP PowerShell to the rescue!

Continue reading “Restore deleted documents already restored by OneDrive”

Reusable ARM template for Web Application

azure resources

SharePoint Framework is the new King of enterprise solutions. Since version 1.4.1, it allows you to easily connect to APIs secured with Azure Active Directory.
As a SharePoint developer, you will likely have to create Azure Web Apps or Functions to be consumed by your SharePoint Framework application. So why not use an ARM template for common scenarios? 
The following ARM template will, hopefully, come in handy and save you some time.

Continue reading “Reusable ARM template for Web Application”

Using pnpm with SPFx 1.6.0

When you create a new SharePoint Framework project, you have the option to use different package managers: npm, pnpm or yarn.

For a long time, I completely ignored this and just used npm. Npm is the slowest option from the list above, but it didn’t really matter as I was installing packages once a week or so. But this is not the case anymore. Simple processes, like upgrading your existing solutions to newer versions of the SharePoint Framework can make you go through that process more times than desired.

In my case, my dev laptop takes a very long time to install or delete node modules, so I found myself looking for alternative solutions.

Continue reading “Using pnpm with SPFx 1.6.0”

CSOM PowerShell – add a field to a list content type

Some people will read the title of this blog post and wonder why I’m writing this when there are plenty of samples to do this online. Some of them written a long time ago. It covers a common requirement: add a SharePoint field to a list content type.

But the reason is simple: I wasn’t able to find a single one that worked on a reliable way.

Continue reading “CSOM PowerShell – add a field to a list content type”