Getting Started With SharePoint Basic Field Operations Using TypeScript With Inheritance

Updated: Mar 29, 2019

Introduction In this article, you will learn how to perform the basic field/column operations (both site scoped and list scoped columns) on SharePoint sites or lists, using TypeScript, with the help of the classes and the variables. In this sample, the field operations for the site and the list are implemented, using the inheritance concept. In my previous article, you saw how to create, retrieve, update, and delete the site fields with the help of an Object Oriented approach.

To learn about TypeScript basics and for the prerequisites to be available on Visual Studio for SharePoint TypeScript programming, you can refer to the article given below.

In my other article, I explained about implementing TypeScript basic examples in SharePoint Visual Studio projects.

This article focuses more on implementing the site column operations for SharePoint sites and the lists, using ECMA script, with the help of TypeScript, using Object Oriented programming concepts (with inheritance).


Class

The class holds the necessary members. This means, the class will hold the necessary variables, constructor and the functions. In this example, two classes will be considered.

  • The base class will hold all the necessary functions with the variables and the constructors related to the site operations.

  • Another class will hold only the variables and the constructor, inheriting the base class. 


Variables

The necessary variables, common for all the functions, are defined as the member variables. In this case, all the variables to be defined in the base class are given below.


public context: SP.ClientContext;  

public site: SP. Site;  

public web: SP.Web;  

public fields: SP.FieldCollection;  


The snippet given below shows the variables used for the second class. The other variables are inherited from the base class.


public lists: SP.ListCollection;  

public list: SP.List;  

public listFields: SP.FieldCollection;  


Constructor