Here we will add columns to a custom list using jsom in SharePoint online (Download PDF for FREE). We will provide the user an input form to enter column name, data type and description and a submit button. Once the user fills the details like column name, data type, and description and clicks on Submit, the column will be created or added to the custom list.
So we have added an HTML form and added the input controls like dropdown list, textbox, and a button etc. And we will have a js file which will have the jsom code to create the column.
HTML File (HTML code for the input controls used to create column):
Here we have taken two text boxes one dropdownlist and a submit button. Here I have hardcorded the dropdown values as the column types as Single line, multi line and number type. Have taken a <p> tag to display the success message. Below is HTML code:
.JS File (Creating columns in List from User inputs)
We have taken a custom list and its name as “department” where the columns will be added. Here we will take the inputs from the user like type of Column, Display Name and description. We will retrive all those inputs and bind using JSOM to create desired columns. Below is JSOM code to create Columns.
As you can see in the below image Display Name, Column Type and description are provided and when we click on Add Column button a popup is displayed as Column is added.
To verify, Open the custom list and you can see the columns has been added to the list like below:
Your FREESharePoint Online Ebook is on its way to your Email Inbox. **************** You will get notification on FREE SharePoint online training, SharePoint webinars, Video Tutorial & also latest FREE PDF tutorials