Posts

Showing posts with the label SharePoint Framework

Logging in SharePoint Framework Solutions

Image
Hi Friends, today I will be discussing about how logging should be done in SharePoint Framework of SPFx solutions. Logging plays a very important role when we need to debug the code in the production for any error and improper or no logging makes it really hard to find the root cause of the issue. While logging we need to take care of the following pointers What information needs to be logged Where to log How long it should be maintained etc... To take on this burden, Microsoft has given a dedicated class for the logging which can be utilized well to make the purpose. @microsoft/sp-core-library This library holds the solution. In sp-core-library Microsoft has exported a class name " LOG " which contains the static methods to write the logs Below the how you can import the class into your solution import { Log } from ' @microsoft/sp-core-library ' ; In this class, you'll get 4 static methods Error Verbose Info Warn Let's have a look on how to use each of the me...

SPFx Chat Bot - using SharePoint Framework Extension

Image
 Hi Friends, Today I have created an SPFx chatbot using the SharePoint Framework extension. This is a small simple to configure bot. It consumes the QnAMaker API to retrieve the answers for the asked questions. The code c an be found here Features !! Easy to configure with little configurations Compatible with the prompts Displays the formatted text as done in the knowledgebase Can filter on single metadata value as well as multi values Option to select the operator for the filter values Its an SPFx extension, so can be deployed at a site collection level or the tenant level   Configuration Needed. Login to the QnAMaker.ai Create the knowledgebase (follow steps here  ) Got to the settings  follow the markers below to retrieve the configuration To get the source code click here Working Demo Steps for deployment There are 2 ways how you can deploy Deploying package directly To deploy the package directly follow the below steps Go to the release page on Github by clicki...

Speed up your development by speeding gulp serve

Image
 Hi friends, I have been not a very big fond of PnP solutions, but sometimes they do really great. Today they have come up with a real booster to the SPFx development. Most of us when working on a big SPFx solution with 5 or more webparts in a solution then we must have felt that the gulp serve process is too slow to build the solution and keeps on decreasing as the solution size increases. Now there is a solution to the problem. Steps... Install the npm package globally run the command install the package execute the command And that's it. Once the npm run serve  is executed, it will call the gulp serve and then see the magic, by changing any of the file and save the file, With my personal experience, it was taking more than 2 mins now it's just the matter of milliseconds Support: It supports the SharePoint Framework 1.4.1 and above (not SP2016), so no worries and build fast. For more documentation on how it does the magic, click here Here is the youtube video which explains ...

Export SharePoint List to Microsoft Word using SharePoint Framework Extension (List view command set)

Image
 Hi Friends, With the introduction of SharePoint list view formatting, I have realized that the scope of playing with the lists has also increased. I was working on one of the list view formatting and thought how if someone wants to export the list items to a Microsoft word? For example, if one creates the FAQ in a SharePoint list, it can be made visibly beautiful using the list view formatted, but if they need to export the same in a word document then? So I came up with the idea of exporting the SharePoint List items in the Microsoft Word format and created an extension which with one click exports the list items in the Microsoft Word. for source code click here. Features..!! Exports all the list items from the SharePoint list to the Microsoft Word with beautiful formatting. Want to export only a few items? Just select the items and click on the export and it will export only the ones you want. Export the items with fields based on the current view fields If the view contains exa...

Know your SharePoint Framework (SPFx) version

Image
Hi Friends, Most of the time when we are working on the SharePoint Framework or SPFx solutions, the version of each component can create issues while building the solutions. One of the common issues is with the SPFx version. SPFx version is the version of the SharePoint Framework yeomen generator installed on your machine. With the difference in the version, a solution might differ in the import versions of other libraries, change in solution scaffolding, and more... ➡️Steps to know your SPFx version Open the console  Type in the following command  npm ls -g --depth=0 @microsoft/generator-sharepoint Hit enter and wait for a few seconds. You'll get the response   Happy Coding #Microsoft #SharePoint #SharePointWidgets

4 Useful VS Code extensions for SharePoint Framework components

Image
Hi Friends, Today I will talk about the most useful VS Code extensions, that will help in the productivity of specifically SharePoint Framework projects. As a developer, we waste a lot of time in the tasks that could be done easily via extensions support or shortcut keys. In this blog post, I will discuss some of these extensions that will increase the productivity and the style of your code. With an increase in productivity, the styling also holds an important value as it makes the code more readable and understandable which increases the focus time. So let's dive then !! VS Code Extensions !! Debugger for Chrome:  A very important extension if you are a SharePoint online developer (developing SharePoint framework components) then it is a must to have this extension. This extension helps in debugging the SharePoint Framework components just as we used to do in the C# server-side coding. For details on how to configure, you ca...

Checking user permission in SharePoint Framework (SPFx) webpart

Image
Hi Friends, Many times we need to show the controls based on the user permission while creating the custom SharePoint Framework (SPFx) webpart. The first thing we look for is the endpoint to retrieve the information from SharePoint. In this blog I will tell you how this can be achieved without any endpoint as this information is already available in the SharePoint Framework (SPFx) webpart. So, if you look into the <WebpartName>webpart.ts file , you can find this information in the current page context this .context.pageContext.web.permissions Now we get three methods with this hasAllPermissions : Checks if the user has all the permissions hasAnyPermissions : Checks if the user has any permission from the collection of permissions hasPermission : Checks if the user has given permission value : Returns the current user permission set Now talking of the permissions, you'll get a variety of permissions. For this SharePoint has the SPPermission class. ...

SharePoint Framework (SPFx) : Cascade dropdown in webpart properties

Image
Hi Friends, In this blog I will be creating a cascade drop down in the webpart properties of a SharePoint Framework - SPFx webpart. In my previous post I have shown how to create a dynamically populated dropdown in the SharePoint Framework SPFx webpart . This blog will be in continuation to that, where I will be extending the previous example to populating the list in the dropdown. In this example I will be showing all the "Views" for the selected list. As we usually comes with the scenario where we need the cascade dropdown. For full code files you can refer here on github. Step 1: Setting up your SharePoint environment If you have not yet setup your SharePoint environment , then refer to my previous blog on Setting up your SharePoint environment . Step 2: Creating a empty SharePoint Framework Project Create a empty SharePoint Framework project. If you are new than refer to my previous article on Set up your new SPFx project .  Step 3: Ins...