-
Notifications
You must be signed in to change notification settings - Fork 0
/
list item creation+jsom.txt
35 lines (30 loc) · 1.02 KB
/
list item creation+jsom.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', listItemCreation);
});
function listItemCreation()
{
var clientContext = new SP.ClientContext.get_current();
var oWebsite = clientContext.get_web();
var oList = oWebsite.get_lists().getByTitle('restlist1');
var newItemInfo=new SP.ListItemCreationInformation();
var newItem=oList.addItem(newItemInfo);
newItem.set_item('Title','106');
newItem.set_item('Employee_x0020_Name','Fahad');
newItem.update();
clientContext.load(newItem);
clientContext.executeQueryAsync(onSuccess,onFailure);
}
function onSuccess(sender,args)
{
alert("listitem created successfully");
console.log("listitem created successfully");
}
function onFailure(sender,args)
{
alert("request failed. Message:"+args.message+"-"+args.stackTrace);
console.log("request failed. Message:"+args.message+"-"+args.stackTrace);
}
</script>