creating sharepoint list item using javascript

To create a sharepoint list item using Javascript we will use lists.asmx web service available in sharepoint.

The Code :
You can call the CreateListItem function (below) in your webpart code(aspx,ascx files)to create a sharepoint list item. CreateListItem function further calls createEnvelope funcion to create a list item.




In ws.open use your server name . If you are using the below code in a subsite then use the url of subsite in ws.open to open up the lists.asmx

eg, use http://servername/subsite1/subsite2/_vti_bin/lists.asmx when you are using code in subsite2.





The Listname in createEnvelope is the list guid and the Field Name would be the internal name\id of the field.

You can also open the lists.asmx webservice in your browser to see more functions. for eg, GetlistItems to query or return all the items in the list and lot more.

0 comments:

Post a Comment

Disclaimer

This is a personal weblog. The opinions expressed here represent my own and not those of my employer or anyone else. Should you have any questions or concerns please e-mail me at sharepointprogrammingblogger@gmail.com .

Copyright (c) 2010 @ myshaepointwork.blogspot.com. All rights are reserved.Do Not Copy.

@ Learning SharePoint.com