I have a list that automatically gets populated when a user fills in a contact form. The value of the fields of the form get submitted to the list with the help of JavaScript. This works very well with my account (I'm admin), but when I use my dummy account I get a message that's similar to "Access denied. You are not authorized to make this edit or to open this source" (I translated it from Dutch to English, might not be a 100% correct translation of the error).
If I edit the permissions of the list, and authorize my dummy account for "full control", then I can fill in the contact form without a problem and it will submit the value of the fields to the list. But I don't want my dummy to have full control. Users won't be allowed to have full control over a list, all they are allowed to do is contribute by making list items. The dummy can only add a new list item when it has the authorization "full control", all other permissions settings and authorizations don't work.
Why exactly is this? How come my dummy is not able to make a new list item? I'm pretty sure it's not because of the JavaScript, since changing the permissions for my dummy for that list worked. I really want end users to be able to only create new list items...
Any suggestion, idea or thought is welcome. I tried everything I know of and so far had no luck so I would really appreciate your help. Thanks!
This part of the code submits the fetched data to the list:
function SaveInContact(Name,Email,Subject,Message) {
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getByTitle('Contact');
var listItemCreationInfo = new SP.ListItemCreationInformation();
var newItem = list.addItem(listItemCreationInfo);
newItem.set_item('Title', Subject);
newItem.set_item('Name',Name);
newItem.set_item('Email',Email);
newItem.set_item('Message',Message);
newItem.set_item('Status','Sent');
newItem.update();
context.executeQueryAsync(Function.createDelegate(this, this.onAddSucceeded), Function.createDelegate(this, this.onAddFailed));
document.getElementById("FeedbackField").innerHTML = "Thank you! Your question has successfully been submitted. ";
}
}
function onAddSucceeded() {
document.getElementById('ClickMeButton').style.color = "green";
}
function onAddFailed(sender, args) {
alert('Error: ' + args.get_message() + '\n'+ args.get_stackTrace());
}