Sunday 20 June 2021

SPFx open source development tools

Node.Js:

It is an open-source, cross-platform runtime environment for developing applications. In SPFx, Node.js has the same role that .NET/IIS Express. And it has NPM, the largeest open source library.

NPM:

Node package manager is a software registry to share software or manage private development.

NPM is the replacement to the NuGet.

NPM included as part of Node.js setup.

Package installation modes:

npm install @package – installs the package

npm install @package –save – installs the package and updates package.json automatically (dependencies section)

npm install @package@version –save-dev – installs the package and updates package.json automatically (devDependencies section)

npm install @package@version –save – installs the package with the specified version and updates package.json automatically (dependencies section)

npm install @package@version –save-dev – installs the package with the specified version and updates package.json automatically (devDependencies section)

Useful npm packages to include in a SPFx solution:

npm install gulp yo @microsoft/generator-sharepoint@<spfx_version> –global

Example: npm install gulp yo @microsoft/generator-sharepoint@1.15.2 –global

npm install @microsoft/microsoft-graph-types –save

npm install @pnp/sp –save

npm install @pnp/graph –save

npm install @fluentui/react –save

npm install @pnp/spfx-controls-react –save

npm install @pnp/spfx-property-controls –save

npm install localforage  –save

npm install @luudjanssen/localforage-cache –save

npm install spfx-fast-serve -g

npm install -g pnpm

Yeoman:

Yeoman is the SharePoint framework’s template engine and it runs on top of Node.js. The templates used by the framework are downloaded from GitHub, which means that you need also to install Git on your machine.

Yeoman is responsible to create the project structure with all the files and folders.

Yeoman is replace to the VS Template.

TypeScript:

It is an open-source language built on JavaScript to be executed on the browser.

It is the preferred programming language to develop in SPFx and it is a maintained by Microsoft.

If you are coming from C#, TypeScript is the easiest way to start developing with script languages, all the concepts like classes and objects are available in TypeScript.

TypeScript is replacement to the C#.

TypeScript concepts: 

const – allows the definition of a variable whose value is not going to be changed. Use this instead of let if the variable value is not going to be changed after its declaration.

let – allows the definition of a variable whose value is going to be changed. Use this instead of const if the variable value is going to be changed after its declaration.

var – allows the definition of a variable whose value is going to be changed. To be avoided since variables declared with var are acessible from any scope (scope (function, module, namespace, global)

type – allows the definition of a data class without any business logic or methods, just data. It can be also useful to avoid the usage of magic strings in the code.

enum – allows the definition of a enumeration

interface – allows the definition of a interface that can then be implemented by a concret class.

class – allows the definition of a class that optionally implements an interface

extends – when used, it allows a class to inherit from another class

export – allows the export of functions, variables, interfaces and classes that can be imported with the import statement

import – allows the import of functions, variables, interfaces and classes exported with the export statement

Yeoman generator:

It is a plugin to scaffold complete projects or useful parts.

Gulp:

It is a task runner that uses Node.JS as platform, it builds system automated tasks like CSS and HTML minification, concatenating library files, and compiling the SASS files tasks can be run using Shell or Bash scripts.

Gulp is replacement of MS Build.

Important Gulp Commands:

gulp trust-dev-cert – installs the development certificate

gulp build – builds the solution, tranforms TypeScript into JavaScript

gulp clean – cleans the solution. Cleans the dist and temp folders from the solution

gulp serve – launches SharePoint Workbench to test web parts in debug mode

gulp serve –nobrowser – allows testing web parts in debug mode but without launching SharePoint Workbench

gulp bundle – bundles the solution and minimizes CSS and JS (in debug mode)

gulp bundle –ship – bundles the solution and minimizes CSS and JS for deployment in SharePoint in production mode (release mode)

gulp package-solution – generates package (.sppkg file) but to run in debug mode

gulp package-solution –ship – generates package (.sppkg file) to run in production modeWebpack - It is a module bundler for bundling JavaScript files & transforming, bundling, or packaging any resource or asset.

Office UI fabric:

It is the front-end toolkit that makes your app or add-in blend seamlessly into Office. It includes all the web components, styles, icons and fonts used by Microsoft SharePoint and other Office applications.

VS Code:

It is a free coding editor which for various JavaScript frameworks & several other languages.

VS Code is replament of VS.

Saturday 19 June 2021

SharePoint Framework(SPFx) Basics

SharePoint Framework is a page and web part model that provides full support for client-side SharePoint development, easy integration with SharePoint data, and extending Microsoft Teams.

With the SharePoint Framework, you can use modern web technologies and tools in your preferred development environment to build productive experiences and apps that are responsive and mobile-ready.

With the SharePoint Framework, we can develop:

  1. Web Parts
  2. Extensions
  3. Library components
  4. Adaptive Card Extensions

Technology stack:

SPFx Development Toolchain: New and the old development model                           

Web Stack

Microsoft Tool

Node.js

.Net Framework

NPM

NuGet

Yeoman

Visual Studio

Gulp.js

MS Build

TypeScript

C#

SPFx web frameworks: React, Angular, and Vue frameworks:

In SPFx if you chose 'No JavaScript Framework' template, webpart contain "webpart.ts" file.

If you chose ‘React’ template, SPFx webpart contains the below 2 files.

  1. webpart.ts file
  2. webpart.tsx file in component folder: TSX allows for embedding JSX elements inside the file, and is largely used by React. TS files are plain old Typescript files and do not support adding JSX Elements.

Quick comparison between the two open-source UI web frameworks – React & Angular:

SPFx React vs Angualr:

React is supported by Microsoft, Angular is supported by Google.

SPFx with React:

It is best for component-based applications. There won't be any page load because in React js we break our application into components. And for each component the application maintains internal state.

Pros

Cons

1. Component and data patterns improve readability, which helps to maintain larger apps.

1. It is not a full framework.

 

2. local development solution packaging (creating .sppkg) is really quick.

2. It allows only 1-way data flow.

3. No HTTP call option.

SPFx with Angular:

Angular is a full-blown web framework by Google instead of patchwork of libraries (much more than react). It is among the robust web frameworks for front-end development. Go for Angular if you want full page experience. It’s a recommended framework if routing, dependency injection & 2-way communication is required a lot.

Pros

Cons

1. It has good code structure (MVC pattern) and market popularity.

1. The full-page experience lacks SharePoint UI reuse.

2. It has routing, dependency injection, HTTP calls etc.

2. It lacks SharePoint friendly components.

3. It allows 2-way communication.

3. SPFx don’t support any default control.

SPFx Open Source Development Tools

Saturday 5 June 2021

Microsoft Flow: query cannot be completed because the number of lookup columns it contains exceeds the lookup column threshold

You'll get this error when you are using Microsoft Flow and if you want to get an item from SharePoint List which has more than 12 lookup columns.

Error:

The query cannot be completed because the number of lookup columns it contains exceeds the lookup column threshold.

clientRequestId: 45c548ed-6957-45ff-ae6b-2d19887a92ad
serviceRequestId: 45c548ed-6957-45ff-ae6b-2d19887a92ad

Why do we get this error?

The error is causing with SQL Server. Each lookup requires a join with another table within SQL Server so Microsoft decided to maximize the number of lookups that can be made to avoid performance degradation.

Initially the limit was set to 8, but since the SharePoint 2013 Post June 2013 CU update, Microsoft has increased this limit to 12.

Columns that are defined as lookup columns?

Below are the column types are defined as lookup columns:

  • Standard Lookup columns
  • Managed metadata columns
  • People and groups columns (These also include the Created by and Modified by fields, see below!)
  • Workflow Status columns
OOTB Lookup columns:
  • Created by
  • Modified by
  • Name (linked to Document)
  • Link (Edit to edit item)
  • Name (linked to Document with edit menu)
  • Type (icon linked to document)
The solution is to create a view in your SharePoint list that has a maximum of 11 lookup columns. Then in Power Automate you add that view and that resolves the issue.

Ref links: