4.1.0 • Published 3 years ago

spfxhelper v4.1.0

Weekly downloads
32
License
MIT
Repository
github
Last release
3 years ago

SharePoint Framework Helper

npm.io 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

SPListOperations

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

MethodsDescription
createFolderInDocLibcreates the folder in document library
createFolderInListcreates the folder in list
createListcreates the list
createListItemcreates the list item
getContentTypesByListReturns the content types associated with the list
getInstancereturns the instance of the class
getListBytitlereturns the list details by title
getListItemByIDget the list items based on the item ID
getListItemsreturns all the list items based on the row count. If row count is not provided will return max i.e.. 100
getListItemsByNextLinkreturns the items based on the next link provided
getListItemsByQueryget the list items based on the query parameter
getListMetadatareturns the list metadata required to create the list
getListsDetailsByBaseTemplateIDReturns the lists based on the template ID
getViewsByListReturns the lists views
getDefaultViewReturns the default view of the list
updateListItemupdates the list item
getLibraryItemByFileIDreturns the file for that specified file ID
getLibraryItemsreturns all the files from the document library

SPFieldOperations

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

MethodsDescription
addColumnToListadd the column to the list
addFieldToViewadds the field to the view in the list
addSiteColumnToListadds the site column to the list
createListColumncreates the list column
createSiteColumncreates the site column
getColumnMetadatareturns the column metadata required for the creation of the column
getFieldByListreturns the field details from the list
getFieldBySitereturns the fields details of the site column
getFieldByViewreturns the field details by view
getFieldsByListreturns all the fields associated with the list
getFieldsByViewreturns all the fields associated with view in a list

SPCommonOperations

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

MethodsDescription
getDocIconByFilesreturns the OOB icons for the file types
getInstancereturns the instance of the class
queryGETResquestmethod to query any custom query with 'GET' verb
queryMERGERequestmethod to query any custom query with 'MERGE' verb
queryPATCHRequestmethod to query any custom query with 'PATCH' verb
queryPOSTRequestmethod to query any custom query with 'POST' verb

SPCore (renamed from SPHelperCommon)

This class contains only static methods and contains the helper methods

MethodsDescription
calculateAgereturns the age from the specified date
getFieldInternalNamereturns the internal name of the field (removes the x0020)
getLocalStoragereturns the local storage object
getParameterValuereturns the parameter value from URL
isEmptyStringchecks for the string emptiness
isNullcheck 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

4.1.0

3 years ago

4.0.8

4 years ago

4.0.7

4 years ago

4.0.5

4 years ago

4.0.6

4 years ago

4.0.4

4 years ago

4.0.3

4 years ago

4.0.2

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.0

5 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.0

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.7

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago