Posts

A Simple Way To Re-use Your Existing Script Editor's customization in SPFx Web Part

Image
When migrating to SharePoint modern experience, one of the questions you will be faced with is how to replace your existing Script Editor customizations  with the new SharePoint Framework since scripting is not allowed in the modern sites, meaning Script Editor web part is not available for use (note: you can enable it if you want but it is not recommended). This may leave you thinking about if you have to go learn TypeScript/React, how long it will take and, if and how you can re-use your existing scripts within SPFx. Well, let me tell you the good news, yes you can re-use your existing scripts and it is simple. But it is recommended that you re-write them in TypeScript/React if budget and time permit. So if your goal is re-using the existing scripts as much as possible in the short term while you learn the new language this post is for you.

This post will explain the general steps to re-using your existing script within an SPFx web part but you may need to make some changes to the …

Automate Removal of Orphan Users from SharePoint Online Using CSOM

If you had just migrated to SharePoint Online, one of the few things you will notice is that removing  a user from Azure Active Directory (AAD) does not automatically remove the user from SharePoint sites. This is by design, it is not a bug. This is to ensure that documents uploaded or created by those users are kept with their names in "Created By" field. So after removing them from AAD you have to go to each site the users have access to and manually remove them. But this poses a huge maintenance problem as you can't possibly keep up with this repetitive task, and even  knowing all the sites the user has access to poses a greater challenge. The best solution is to write a daemon application to handle such task.

If you already find yourself in this situation and need a solution, just copy and paste the code below in a console application:

We need to loop through a list of all AAD users and compare them with users in our SharePoint site collections. To get this list, ad…

Custom Theme Applicator for SharePoint Online Modern Experience

Image
In most cases you have to customize the modern experience based on your organization's branding or identity. Microsoft has given us a variety of options to do that; we have PowerShell cmdlets, CSOM and REST API. It seems most people prefer to just use PowerShell for this purpose as you get to see most blogs discussing how to create a custom theme using PowerShell. But to me, it's very tedious to work with PowerShell when you are testing different shades of color to use in your custom theme.  I prefer an interface that allows me to click buttons to create or update, retrieve an existing theme and even remove it without working with a set of commands. It's a faster for me :). So to avoid the hassle of working with commands each time I want to test my theme, I decided to develop a SharePoint add-in  using SharePoint theming REST API . You can download the app here in the app.publish folder. Once downloaded, upload the app to your App catalog and it's ready for use! Here i…

Generate Word Document From A SharePoint List Item Using Microsoft Flow

Image
Recently I took a deep dive into Microsoft flow, and the first task I gave myself was using MS flow for one of the projects I have done in the past. In my former company I was tasked by the legal team to develop a solution that auto-generates contract document based on a predefined template and route it for approval. They wanted to standardized the document so that any contract document leaving the bank to the customers will have the same format. I did this without writing a single line of code, using SharePoint Designer Workflow, List and InfoPath I was able to meet their requirements.

Initially doing this in MS flow seemed impossible, but because MS flow has an action that supports REST APIs I was determined to code it if required. But it turns out to be simpler than it seemed. I used a REST API to achieve it though, but later discovered an action that saved me the two steps introduced by the REST API. I will cover the two methods in this post.

We will start by creating a content t…

Login With Office 365 Account Using Microsoft Active Directory Authentication Library (MS ADAL) Plugin In Ionic 3

Image
In this post we will be looking at how to use cordova and  ms-adal Native plugin to authenticate into your Ionic mobile app.
We will build a simple app that allows users to login using their office 365 accounts. Once they login,  a personalized welcome message will be displayed to the users using their profile information fetched via MS Graph API.
I decided to blog about my experience because I couldn't come across any comprehensive information on using MS ADAL authentication in Ionic unlike what you get for cordova Facebook and Google plugin. So, I hope this post will help someone.

The first thing to do is to register our app at https://apps.dev.microsoft.com.
Navigate to the url above and sign in with your Microsoft account, It could be a personal account or office account. It doesn't really matter. But if you want to see your apps in your azure dashboard, then use your office account.

Type MS Adal Demo in Application Name field
Ensure Guided Setup is selected, then click C…

Calling Microsoft Graph API from an Angular 5 Single Page Application (SPA)

Image
In this post I will be discussing how to use OAuth 2 Implicit Grant to authenticate users with Azure AD and call Microsoft Graph ApI from an Angular 5 Single Page Application. The idea of consuming Microsoft Graph API in an Angular app was prompted by a discussion I had with a contact on LinkedIn recently, asking if I had worked with MS Graph API before, and since I had started learning Angular to broaden my skill set, I decided to create a simple SPA that will authenticate users via Azure AD and display users's profile information using MS Graph API. So if you are looking for how to do that, you are in the right place. I will be sharing my experience with you in this post and I hope you will find this it useful.

I will break this post down into 3 categories:
Creating an Angular 5 ApplicationAuthenticating and Authorizing your AppCalling Microsoft Graph APICreating An Angular 5 Application
Since this post is not about angular per se, I will not be going into nitty-gritty of settin…