Skip to content

Core Operations

Sumit Kanchan edited this page Mar 3, 2020 · 2 revisions

SharePoint Online Core Operations

In this I will explain the methods and their use in the SPCore Class. To install the package do

> npm i spfxhelper

And then import the following in the code file

import { SPCore } from 'spfxhelper';

In this class all methods are static and wraps most of the Microsoft OOB methods.

isEmptyString()

  • This method checks if the current string is a non-empty string, which includes undefined, null , "" etc..
 SPCore.isEmptyString("YOUR STRING");

Parametrs

  • value: string value that needs to be checked

Return type: boolean


isNull()

  • This method checks if current object is null or undefined
 SPCore.isNull(obj);

Parametrs

  • value: object value that needs to be checked

Return type: boolean


getFieldInternalName()

  • This method returns the internal name by replacing the empty space with "x0020"

Note: It does not query SharePoint to get the internal name of the field, instead just replaces

 SPCore.getFieldInternalName("Field display name");

Parametrs

  • value: display name of the field

Return type: string


getParameterValue()

  • This method returns the parameter value from the url
 SPCore.getParameterValue(url, parameterName);

Parametrs

  • url: url from which parameter needs to be extracted
  • parameterName : Parameter name whose value needs to be extracted

Return type: string


calculateAge()

  • This method calculates and returns the age based on the date parameter in ISO format
let ageOfChild:number =  SPCore.calculateAge("DateAsISOString");

Parametrs

  • dateString: date as ISO string

Return type: number


getLocalStorage()

  • This method returns the local storage object if exists
let loaclStorage:Storage =  SPCore.getLocalStorage();

Parametrs

  • No parameters required

Return type: number