I get the following error when I try to add a record to a Sharepoint List.
The SOAP response indicates that an error occurred on the server:
Server was unable to process request. ---> Object reference not set to an instance of an object.
File:script.js
Line:120
Line 120 is XDocument.DataAdapters["Submit"].Submit();
Does anyone know why? I am submitting to the UpdateListItem web service.
Code:
function btnAdd::OnClick(eventObj)
{
var root = XDocument.DOM;
// Retrieve the values for the calendar item
var title = root.selectSingleNode("my:myFields/my:myFields1/my:Title").text;
var location = root.selectSingleNode("my:myFields/my:myFields1/my:Location").text;
var description = root.selectSingleNode("my:myFields/my:myFields1/my:Description").text;
var batch = XDocument.DataObjects["EventCAML"].DOM;
// Set the location
batch.selectSingleNode("/Batch/Method/Field[@Name='Title']").text = title;
// Set the location
batch.selectSingleNode("/Batch/Method/Field[@Name='Location']").text = location;
// Set the location
batch.selectSingleNode("/Batch/Method/Field[@Name='Description']").text = description;
// Submit the item details to the web service to update the calendar
XDocument.DataAdapters["Submit"].Submit();
XDocument.UI.Alert( "Change Request has been successfully saved" );
}