Posts

Showing posts from 2018

Time based query issue in SharePoint Framework

Image
Issue: Whenever you are making query to the SharePoint online using the REST API and your query is based on the time stamp, remember that SharePoint treat your time as the GMT timezone. So if you want to fetch information based on local time zone which we usually do, always set the offset and also include the daylight saving. The same is true even you are trying to put in some data to the SharePoint. You will be saving the local timezone but SharePoint will consider it as GMT time zone , and there you won’t be able to save/retrieve the correct records based on the time zone. Solution Solution is simple. SharePoint Framework webpart/extension offers this capability OOB, but there were no articles i was able to find. // will get the final offset in minutes    let finalOffset : number = this . context . pageContext . web . timeZoneInfo . offset + this . context . pageContext . web . timeZoneInfo . daylightOffset    // Now set the required time in

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

Show your SharePoint Framework web part in full Width layout

Image
Hi friends, By default when you create a full width layout we can have only 2 web part by default Image WebPart Hero WebPart So it becomes very difficult if you are creating some webpart which needs to be shown as a full width webpart..  Now the good news is that , it is now possible to show your custom control creating in SharePoint Framework to be shown on the full width. With just minor changes you can achieve this. Open your webpart's manifest file and add the property " supportsFullBleed: true ". This property will allow the webpart to be shown as an option in the full width. Below is the config file where change needs to be made As shown in the image below the webpart is shown as an option. Happy Coding - Sumit Kanchan

SharePoint Framework (SPFx) - Adding dynamic values in (SPFx) webpart properties

Image
Hi Friends, We usually have to add the dynamic values to the web part properties. In this blog I will be showcasing the how you can add the dynamic values to the web part properties. In this blog I will showcasing how you can fill in the drop-down values with the Title of the lists. All the lists will be fetched and then will be added to one of the web part properties. On selection of the drop-down you can see the list selected. Step 1 : Create an empty SharePoint project .  To learn how to create SharePoint Framework Project you can refer to my previous post Setup your new SPFx Project . If you have not setup your environment you can refer my blog  3 Steps to Setup your SharePoint Framework Environment . In my case I have crated Project with the name " spfx-dynamic-values-in-web-part-properties " WebPart with the name " demoDynamicValuesInWebP