Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Add A List Item In SharePoint Using JSOM (Announcement List)
WhatsApp
Gowtham Rajamanickam
5y
9.1
k
0
1
25
Blog
Steps
Open your SharePoint site.
Edit SharePoint page and add a Content Editor WebPart.
Add JavaScript code given below into CEWP.
Save the page and hit F5.
Code snippet
$(document).ready(function
{
deletelistitem();
});
function deletelistitem() {
var clientContext =
new
SP.ClientContext(https:
//gowtham.sharepoint.com/tutorials");
var oList = clientContext.get_web().get_lists().getByTitle(
'Announcements'
);
var itemCreateInfo =
new
SP.ListItemCreationInformation();
this
.oListItem = oList.addItem(itemCreateInfo);
oListItem.set_item(
'Title'
,
'Test Item!'
);
oListItem.set_item(
'Body'
,
'This Item has added Programmatically!'
);
oListItem.update();
clientContext.load(oListItem);
clientContext.executeQueryAsync(Function.createDelegate(
this
,
this
.onQuerySucceeded), Function.createDelegate(
this
,
this
.onQueryFailed));
}
function onQuerySucceeded() {
alert(
'Item created sucessfully: '
+ oListItem.get_id());
}
function onQueryFailed(sender, args) {
alert(
'Request failed. '
+ args.get_message() +
'\n'
+ args.get_stackTrace());
}
SharePoint
JSOM
Up Next
Update A List Item In SharePoint Using CSOM (Announcement List)
Ebook Download
View all
SharePoint Online And Office 365 Administration
Read by 3.6k people
Download Now!
Learn
View all
Membership not found