{"id":6110,"date":"2020-05-18T14:10:52","date_gmt":"2020-05-18T14:10:52","guid":{"rendered":"https:\/\/www.softreetechnology.com\/?p=6110"},"modified":"2020-05-18T14:10:52","modified_gmt":"2020-05-18T14:10:52","slug":"creating-list-and-columns-using-sharepoint-hosted-add-ins","status":"publish","type":"post","link":"https:\/\/softreetechnology.com\/blog\/office-365\/creating-list-and-columns-using-sharepoint-hosted-add-ins\/","title":{"rendered":"Creating List and Columns Using SharePoint Hosted Add-ins"},"content":{"rendered":"\n<p><strong><span style=\"text-decoration: underline;\">Introduction <\/span>:<\/strong><\/p>\n\n\n\n<p>              In this blog, I have described step by step how to create a list and column using SharePoint-self hosted Add-ins. To create the List and List Columns using SharePoint Hosted Apps, you have to follow the below steps. <\/p>\n\n\n\n<p><strong>Step 1- <\/strong>Create a SharePoint Hosted App project.<br><strong>Step 2-<\/strong> Write HTML code under Default.aspx.<br><strong>Step 3-<\/strong> Add JavaScript code under App.js file.<br><strong>Step 4-<\/strong> Deploy the Project.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong><span style=\"text-decoration: underline;\">Create a SharePoint Hosted App project :<\/span><\/strong><\/li><\/ol>\n\n\n\n<ul class=\"wp-block-list\"><li>Open visual\nstudio to create a SharePoint hosted Add-In. First, click the file menu option\nthen click the new item. After that we can see the option for Project item, now\nclick on the same option.<\/li><li>Expand the office\/SharePoint\ntab and select SharePoint Add-in. Enter the project name &amp; location of the\nproject then hit the OK button.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/05\/1-2-1024x711.png\" alt=\"\" class=\"wp-image-6111\" width=\"682\" height=\"473\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Select the SharePoint site URL\n&amp; Hosted add-in as shown below and then click on the Next button.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/05\/2-2-1024x611.png\" alt=\"\" class=\"wp-image-6122\" width=\"583\" height=\"348\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Now it will ask for your\ncredentials. Enter the user Credentials (Username &amp; Password) and Click the\n&#8220;Sign-in&#8221; Option.<\/li><li>Once the SharePoint hosted App\nis created, then we can add our code.<\/li><\/ul>\n\n\n\n<p>2. <strong><span style=\"text-decoration: underline;\">Write HTML code under Default.aspx :<\/span><\/strong><\/p>\n\n\n\n<p>Go to Default.aspx page. Create a label and a button inside the div class as shown below. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;tr>\n       &lt;td>&lt;label id=\"btnCreate\" style=\"font-size:large;font-style:normal\">Enter The List Name You Want To Give&lt;\/label>&lt;\/td> \n       &lt;td>&lt;input type=\"text\" id=\"txtListName\" name=\"txtListName\" \/>&lt;\/td>\n       &lt;td>&lt;input type=\"button\" id=\"crtBtn\" value=\"CreateList\" \/>&lt;\/td>\n&lt;\/tr><\/code><\/pre>\n\n\n\n<p>    3.  <strong><span style=\"text-decoration: underline;\">Add Javascript code under App.js file :<\/span><\/strong><\/p>\n\n\n\n<p>    Go to App.js . Add your coding.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function initializePage() {\n    var context = SP.ClientContext.get_current();\n    var user = context.get_web().get_currentUser();\n    \n    $(document)x.ready(function () {  $(\"#crtBtn\").on('click', function () {\n            CreateList();\n        });\nfunction getURLParameters(param)\n    {\n        var params = document.URL.split('?')[1].split('&amp;');\n        var strParams = '';\n        var plength = params.length;\n        for (var i = 0; i &lt; plength; i = i + 1) {\n            var singleParam = params[i].split('=');\n            if (singleParam[0] == param) \n               {\n                 return singleParam[1];\n               }\n           }\n        }\n\n             \n   function CreateList() \n    {\n      var hostUrl = decodeURIComponent(getURLParameters(\"SPHostUrl\"));\n      var clientContext = new SP.ClientContext.get_current();\n      var hostContext = new SP.AppContextSite(clientContext, hostUrl);\n      var oWeb = hostcontext.get_web();\n      var value =document.getElementById(\"txtListname\").value.toLowerCase();\n      var listCreation = new SP.ListCreationInformation();\n      listCreation.set_title(value);\n      listCreation.set_templateType(SP.ListTemplateType.genericList);\n      var mySpList = oWeb.get_lists().add(listCreationInfo);\n      var fieldColl = mySpList.get_fields();\n      var spTxtField = fieldColl.addFieldAsXml('&lt;Field Type=\"Text\" DisplayName=\"Employee Name\" Name=\"Employee Name\" \/>', true, SP.AddFieldOptions.addToDefaultContentType);\n     spTxtField.set_title(\"Employee Name\");\n     var spDescripField = fieldCol.addFieldAsXml('&lt;Field Type=\"Note\" DisplayName=\"Address\" Name=\"Address\" \/>', true, SP.AddFieldOptions.addToDefaultContentType);\n    spDescripField.set_title(\"Address\");\n    mySpList.update();\n    clientContext.executeQueryAsync(function () {\n        alert(\"successfully Created The List and List Field\");\n    },\n       function (sender, args) {\n           alert('Error: ' + args.get_message() + '\\n' + args.get_stackTrace());\n       });\n   }\n}<\/code><\/pre>\n\n\n\n<p>4. <strong><span style=\"text-decoration: underline;\">Deploy the Project :<\/span><\/strong><\/p>\n\n\n\n<p>Go to the <strong>&#8220;Solution Explorer&#8221;<\/strong>, Right-click on the project and click on Deploy.  <\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/05\/3-1.png\" alt=\"\" class=\"wp-image-6113\" width=\"431\" height=\"300\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Once you deploy it, enter your office365\n     credentials.<\/li><li>Now you can see your App page.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/05\/4.png\" alt=\"\" class=\"wp-image-6114\" width=\"492\" height=\"56\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Enter the list name and click on the CreateList butto<\/li><li>Now you can see the list in your sitecollection.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/05\/5-1024x406.png\" alt=\"\" class=\"wp-image-6115\" width=\"600\" height=\"238\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>And the NewList contains two columns as shown below.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/05\/6-1024x377.png\" alt=\"\" class=\"wp-image-6116\" width=\"543\" height=\"200\"\/><\/figure>\n\n\n\n<p><strong><span style=\"text-decoration: underline;\">Keywords:<\/span><\/strong><\/p>\n\n\n\n<p> \u2022    Using SharePoint hosted app how to create list and columns.<br> \u2022    Creation of list using SharePoint hosted adding.<br> \u2022    Programmatically creating list and columns using SharePoint hosted app.<br> \u2022    Create custom list and column programmatically using js.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction : In this blog, I have described step by step how to create a list and column using SharePoint-self hosted Add-ins. To create the List and List Columns using SharePoint Hosted Apps, you have to follow the below steps. Step 1- Create a SharePoint Hosted App project.Step 2- Write HTML code under Default.aspx.Step 3- Add JavaScript code under App.js [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[127],"tags":[],"class_list":["post-6110","post","type-post","status-publish","format-standard","hentry","category-office-365"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Creating List and Columns Using SharePoint Hosted Add-ins - Softree Technology<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/softreetechnology.com\/blog\/office-365\/creating-list-and-columns-using-sharepoint-hosted-add-ins\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Creating List and Columns Using SharePoint Hosted Add-ins - Softree Technology\" \/>\n<meta property=\"og:description\" content=\"Introduction : In this blog, I have described step by step how to create a list and column using SharePoint-self hosted Add-ins. To create the List and List Columns using SharePoint Hosted Apps, you have to follow the below steps. Step 1- Create a SharePoint Hosted App project.Step 2- Write HTML code under Default.aspx.Step 3- Add JavaScript code under App.js [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/softreetechnology.com\/blog\/office-365\/creating-list-and-columns-using-sharepoint-hosted-add-ins\/\" \/>\n<meta property=\"og:site_name\" content=\"Softree Technology\" \/>\n<meta property=\"article:published_time\" content=\"2020-05-18T14:10:52+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Creating List and Columns Using SharePoint Hosted Add-ins - Softree Technology","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/softreetechnology.com\/blog\/office-365\/creating-list-and-columns-using-sharepoint-hosted-add-ins\/","og_locale":"en_US","og_type":"article","og_title":"Creating List and Columns Using SharePoint Hosted Add-ins - Softree Technology","og_description":"Introduction : In this blog, I have described step by step how to create a list and column using SharePoint-self hosted Add-ins. To create the List and List Columns using SharePoint Hosted Apps, you have to follow the below steps. Step 1- Create a SharePoint Hosted App project.Step 2- Write HTML code under Default.aspx.Step 3- Add JavaScript code under App.js [&hellip;]","og_url":"https:\/\/softreetechnology.com\/blog\/office-365\/creating-list-and-columns-using-sharepoint-hosted-add-ins\/","og_site_name":"Softree Technology","article_published_time":"2020-05-18T14:10:52+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/softreetechnology.com\/blog\/office-365\/creating-list-and-columns-using-sharepoint-hosted-add-ins\/#article","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/office-365\/creating-list-and-columns-using-sharepoint-hosted-add-ins\/"},"author":{"name":"admin","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b"},"headline":"Creating List and Columns Using SharePoint Hosted Add-ins","datePublished":"2020-05-18T14:10:52+00:00","mainEntityOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/office-365\/creating-list-and-columns-using-sharepoint-hosted-add-ins\/"},"wordCount":324,"commentCount":0,"publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/office-365\/creating-list-and-columns-using-sharepoint-hosted-add-ins\/#primaryimage"},"thumbnailUrl":"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/05\/1-2-1024x711.png","articleSection":["Office 365"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/softreetechnology.com\/blog\/office-365\/creating-list-and-columns-using-sharepoint-hosted-add-ins\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/softreetechnology.com\/blog\/office-365\/creating-list-and-columns-using-sharepoint-hosted-add-ins\/","url":"https:\/\/softreetechnology.com\/blog\/office-365\/creating-list-and-columns-using-sharepoint-hosted-add-ins\/","name":"Creating List and Columns Using SharePoint Hosted Add-ins - Softree Technology","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/office-365\/creating-list-and-columns-using-sharepoint-hosted-add-ins\/#primaryimage"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/office-365\/creating-list-and-columns-using-sharepoint-hosted-add-ins\/#primaryimage"},"thumbnailUrl":"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/05\/1-2-1024x711.png","datePublished":"2020-05-18T14:10:52+00:00","breadcrumb":{"@id":"https:\/\/softreetechnology.com\/blog\/office-365\/creating-list-and-columns-using-sharepoint-hosted-add-ins\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/softreetechnology.com\/blog\/office-365\/creating-list-and-columns-using-sharepoint-hosted-add-ins\/"]}]},{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/office-365\/creating-list-and-columns-using-sharepoint-hosted-add-ins\/#primaryimage","url":"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/05\/1-2-1024x711.png","contentUrl":"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/05\/1-2-1024x711.png"},{"@type":"BreadcrumbList","@id":"https:\/\/softreetechnology.com\/blog\/office-365\/creating-list-and-columns-using-sharepoint-hosted-add-ins\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/softreetechnology.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Creating List and Columns Using SharePoint Hosted Add-ins"}]},{"@type":"WebSite","@id":"https:\/\/softreetechnology.com\/blog\/#website","url":"https:\/\/softreetechnology.com\/blog\/","name":"Softree Technology","description":"Celebrating 10+ Years in SharePoint Consulting !","publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/softreetechnology.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":"Organization","@id":"https:\/\/softreetechnology.com\/blog\/#organization","name":"Softree Technology","url":"https:\/\/softreetechnology.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","contentUrl":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","width":844,"height":230,"caption":"Softree Technology"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b","name":"admin","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/softreeconsulting.com"],"url":"https:\/\/softreetechnology.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/6110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/comments?post=6110"}],"version-history":[{"count":0,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/6110\/revisions"}],"wp:attachment":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/media?parent=6110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/categories?post=6110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/tags?post=6110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}