Please note that I'm doing this for the first time.
I want to add an element to a list via JavaScript. Therefore, I tried this:
function fillStandard() {
console.log("Standard");
var posInvest = "Invest";
var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('Position');
var item = new SP.ListItemCreationInformation();
var oListItem = oList.addItem(item);
oListItem.set_item('PosType', posInvest);
clientContext.load(oListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded(sender, args) {
console.log("successfully executed");
}
function onQueryFailed(sender, args) {
console.log("failed");
alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
}
The problem is that my onQueryFailed
tells me:
request failed The field or property PosType does not exist
undefined
But when I look at my list Position
it does have a column called PosType
:
What am I doing wrong?