Skip to content

SharePoint Framework : This repository will contain all the base methods that will improve the coding speed of the developer while creating a SharePoint Framework Solution

License

Notifications You must be signed in to change notification settings

SumitKanchan4/SPFx

Repository files navigation

SharePoint Framework Helper

GitHub release npm npm bundle size npm npm

SharePoint Framework Helper

In the need to develop the solution faster and easier I have created a npm package, which will give you the flexibility to enjoy the much used logic handy and easy when writing code for SharePoint framework client side webparts or SharePoint framework extensions.

This npm package contains the most commonly used functions or I should say the operations that are used almost in every SPFx client side webpart or SPFx extensions. Using this npm package you can create your webparts much more easily and faster. This is very simple and handy.

This npm package code is also available on GitHub so if you are interested you can have a look at the implementation as well, or even you can request for the addition of new methods that you feel might help others as well.

Why to use ?

  • This library contains handy functions that will save lot of man hours in implementing
  • Well designed results so it will help in writing the code efficiently
  • Well broken into the type of operation, so include only the class that is most useful to you

How to use ?

To install the package execute the below command

> npm i spfxhelper

And then import the following in the code file

import { "CLASS_NAME" } from 'spfxhelper';

Inside the library

  • This library contains a number of classes

This class contains all the methods that are responsible for the interaction of the SharePoint List.

Methods Description
createFolderInDocLib creates the folder in document library
createFolderInList creates the folder in list
createList creates the list
createListItem creates the list item
getContentTypesByList Returns the content types associated with the list
getInstance returns the instance of the class
getListBytitle returns the list details by title
getListItemByID get the list items based on the item ID
getListItems returns all the list items based on the row count. If row count is not provided will return max i.e.. 100
getListItemsByNextLink returns the items based on the next link provided
getListItemsByQuery get the list items based on the query parameter
getListMetadata returns the list metadata required to create the list
getListsDetailsByBaseTemplateID Returns the lists based on the template ID
getViewsByList Returns the lists views
getDefaultView Returns the default view of the list
updateListItem updates the list item
getLibraryItemByFileID returns the file for that specified file ID
getLibraryItems returns all the files from the document library

This is the class responsible for the operations related to SharePoint Fields.

Methods Description
addColumnToList add the column to the list
addFieldToView adds the field to the view in the list
addSiteColumnToList adds the site column to the list
createListColumn creates the list column
createSiteColumn creates the site column
getColumnMetadata returns the column metadata required for the creation of the column
getFieldByList returns the field details from the list
getFieldBySite returns the fields details of the site column
getFieldByView returns the field details by view
getFieldsByList returns all the fields associated with the list
getFieldsByView returns all the fields associated with view in a list

This class is the extension of the base class where one can query the API's which are not available as methods in other classes

Methods Description
getDocIconByFiles returns the OOB icons for the file types
getInstance returns the instance of the class
queryGETResquest method to query any custom query with 'GET' verb
queryMERGERequest method to query any custom query with 'MERGE' verb
queryPATCHRequest method to query any custom query with 'PATCH' verb
queryPOSTRequest method to query any custom query with 'POST' verb

SPCore (renamed from SPHelperCommon)

This class contains only static methods and contains the helper methods

Methods Description
calculateAge returns the age from the specified date
getFieldInternalName returns the internal name of the field (removes the x0020)
getLocalStorage returns the local storage object
getParameterValue returns the parameter value from URL
isEmptyString checks for the string emptiness
isNull check for the object null

SPLogger

This class has been removed from the library. Instead use the OOB class Log in sp-core-library.

import { Log } from '@microsoft/sp-core-library';

Use the following methods

static error(source: string, error: Error, scope?: ServiceScope): void;
static info(source: string, message: string, scope?: ServiceScope): void;
static verbose(source: string, message: string, scope?: ServiceScope): void;
static warn(source: string, message: string, scope?: ServiceScope): void;

Do share how I can improve this library, so it can help all the SharePoint community

Happy Coding

#SharePointWidgets #MicrosoftSharePoint

Sumit Kanchan

About

SharePoint Framework : This repository will contain all the base methods that will improve the coding speed of the developer while creating a SharePoint Framework Solution

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published