Previous post basic of JavaScript Object Model(JSOM) in this post we will see the implementation .
By Creating List of SharePoint 2013
using JavaScript Object Model (JSOM)
<script type="text/javascript" src="../Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js"></script>
<script type="text/javascript" src="/_layouts/15/init.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>
<script type="text/ecmascript">
function createCustomList() {
var clientContext = new SP.ClientContext.get_current();
var osite = clientContext.get_web();
var listCreation = new SP.ListCreationInformation();
listCreation.set_title('MyCustomList'); // name of
list
listCreationInfo.set_description('Created by
JSOM'); // list description
listCreation.set_templateType(SP.ListTemplateType.genericList); //list type
osite.get_lists().add(listCreation);
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded),// on success
Function.createDelegate(this, this.onQueryFailed) // on failed
);
}
function onQuerySucceeded() {
alert("Created List");
}
function onQueryFailed(sender, args) {
alert("Failed list creation");
}
</script>
We can use following templates to create list
· SP.ListTemplateType.GenericList
· SP.ListTemplateType.DocumentLibrary
· SP.ListTemplateType.Survey
· SP.ListTemplateType.Announcements
· SP.ListTemplateType.Contacts
· SP.ListTemplateType.Events
· SP.ListTemplateType.Tasks
· SP.ListTemplateType.DiscussionBoard
· SP.ListTemplateType.PictureLibrary
· SP.ListTemplateType.DataSources
· SP.ListTemplateType.XmlForm
· SP.ListTemplateType.NoCodeWorkflows
· SP.ListTemplateType.WorkflowProcess
· SP.ListTemplateType.WebPageLibrary
· SP.ListTemplateType.CustomGrid
· SP.ListTemplateType.WorkflowHistory
· SP.ListTemplateType.GanttTasks
· SP.ListTemplateType.IssuesTracking
Thank you very
much
Fahadullah Karimi
SharePoint Specialist
Client Side Object Model (CSOM) in SharePoint 2013 | Configure Business Data Connectivity Service in SharePoint 2013 |
No comments:
Post a Comment