-
Notifications
You must be signed in to change notification settings - Fork 3
Core Operations
Sumit Kanchan edited this page Mar 3, 2020
·
2 revisions
In this I will explain the methods and their use in the SPCore Class. To install the package do
> npm i spfxhelperAnd 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.
- This method checks if the current string is a non-empty string, which includes undefined, null , "" etc..
SPCore.isEmptyString("YOUR STRING");- value: string value that needs to be checked
- This method checks if current object is null or undefined
SPCore.isNull(obj);- value: object value that needs to be checked
- 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");- value: display name of the field
- This method returns the parameter value from the url
SPCore.getParameterValue(url, parameterName);- url: url from which parameter needs to be extracted
- parameterName : Parameter name whose value needs to be extracted
- This method calculates and returns the age based on the date parameter in ISO format
let ageOfChild:number = SPCore.calculateAge("DateAsISOString");- dateString: date as ISO string
- This method returns the local storage object if exists
let loaclStorage:Storage = SPCore.getLocalStorage();- No parameters required