SharePoint アドインでリスト アイテムを作成する必要があります。OfficeDev Github サイトhereから機能を取得しました。関数を呼び出すと、「this」が最初に表示される行で失敗します。
エラー: 未定義または null 参照のプロパティ 'oListItem' を設定できません
// line calling the function
createDELListItem(document.getElementById("resultpanel"), uniqueID, "MTD_On_Demand");
// function
function createDELListItem(resultpanel, extractionID, extractionType) {
var clientContext;
var oWebsite;
var oList;
var itemCreateInfo;
clientContext = new SP.ClientContext.get_current();
oWebsite = clientContext.get_web();
oList = oWebsite.get_lists().getByTitle("Global_Variable_Store");
itemCreateInfo = new SP.ListItemCreationInformation();
// Line throwing the "null or undefined" error
this.oListItem = oList.addItem(itemCreateInfo);
//A guid to send with message that uniquely identifies the list item.
this.oListItem.set_item("ExtractionID", extractionID);
//A brief title (description) of the variable set here in this list item.
this.oListItem.set_item("Extraction Type", extractionType);
//The Variable name
this.oListItem.set_item("StartTime", convertThisDate);
//The process descriptor that set the variable. This is set by the code.
this.oListItem.update();
clientContext.load(this.oListItem);
clientContext.executeQueryAsync(
Function.createDelegate(this, successHandler),
Function.createDelegate(this, errorHandler)
);
function successHandler() {
resultpanel.innerHTML = "Go to the <a href='../Lists/Global_Variable_Store'>list</a> to see your new item.";
}
function errorHandler() {
resultpanel.innerHTML = "Request failed: " + arguments[1].get_message();
}
}