Steps
- Open your SharePoint site.
- Edit SharePoint page and add a Content Editor WebPart.
- Add a JavaScript code given below in to CEWP.
- Save the page and hit F5.
Code snippet
- $(document).ready(function
- {
- CreateTaskList();
- });
- function CreateTaskList() {
- var clientContext = new SP.ClientContext(https://gowtham.sharepoint.com/tutorials");
- var web = clientContext.get_web();
- var listInfo = new SP.ListCreationInformation();
- listInfo.set_title('Tasks List');
- listInfo.set_description('Task List created by JSOM');
- listInfo.set_templateType(SP.ListTemplateType.tasksWithTimelineAndHierarchy);
- listInfo.set_templateFeatureId('B9CE21G7-A437-4A7E-8BC6-946378C850A');
- var list = web.get_lists().add(listInfo);
- }
- function onQuerySucceeded() {
- alert('List created sucessfully: ' + oListItem.get_id());
- }
- function onQueryFailed(sender, args) {
- alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
- }

Join the conversation! Your thoughts help the community grow.