2

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());
}
  • At what point are you getting the error? Upon submission? or Prior to that. – BlueBird Oct 21 '13 at 14:09
  • Please provide your code, it is hard to help without knowing what is going wrong, and where – Robert Lindgren Oct 21 '13 at 14:28
  • I get the error upon trying to insert the values into the list. I'll add the code to the question, I do however doubt the problem is located there since I can add a new list item through the contact form (which is really just written in HTML, it fetches the value from the input fields based on their ID's). – Magali Oct 21 '13 at 14:54
  • @Magali your code is fine! its the permission on the list that is going wrong! – Ali Jafer Oct 21 '13 at 15:17
0

Fair enough you have given the user edit permission but what about add permission on the give list? without the add permission the user cant add an item.

another way would be to within code add runwithelevatedprivlages block that would do what is required if you dont want to give any users other permissions as it would run under pool account for the given task!

by add i mean the Contribute permission! please read up on types of permissons. as iv noted if you dont want Contribute permission than do it through code and encapsulate what you want the user todo with runwithelevatedpriv code block and leave the given user as read only ;) !

http://technet.microsoft.com/en-us/library/cc721640.aspx

or do it through sharepoint and create a new permission that can add an item

http://technet.microsoft.com/en-us/library/cc263239.aspx

also like to note how are you assigning the permission? is it on the list? if so you need to break the permission. If not than its by default taken from the site permission please check this link out aswell:

http://technet.microsoft.com/en-us/library/jj219771.aspx

  • The "Contribute" permission level is what got me going just now, I found out I hadn't ticked a box named "Override Check-Out". I ticked it and now it works. Didn't expect that one to be the problem though. Thanks! – Magali Oct 22 '13 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.