2

I have a SharePoint list form which has been customized using SharePoint Designer. I am using the script to populate logged in user details in the form.

I have full control of the site and list. So when I log in everything is working as expected. But when someone with Contribute/Edit permission is trying to log in they are getting the following error:

Access denied. You do not have permission to perform this action or access this resource.

Because of this, the user details are not populated correctly. Ideally, this should be working for anyone with contribute permission.

Can someone help?


<script type="text/javascript">
    $(document).ready(function() {
        var loginName = "";
        var userid = _spPageContextInfo.userId;
        var mgr=GetCurrentUser();
    });
    function GetCurrentUser() {
        var mgr;
        var requestUri =_spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties";
    }
</script>
  • 2
    Is script saved in other document library? If yes, then there might be possibility that user do not have access to script. – P S Dec 23 '19 at 13:04
  • How you have added script to your page? Is it stored somewhere else maybe in style library/site assets? Can you please add code snippet you are using?? – Ganesh Sanap Dec 23 '19 at 13:29
  • Please ensure the script you used that should be published. If it is not working then try to use those script code as Internally. – Karthikeyan Ganesan Dec 24 '19 at 3:43
  • @PS Yes the script is in Site Assets and the user is having contribute permission to this. – shoegal91 Dec 24 '19 at 5:13
  • @GaneshSanap I have linked the script from site assets in a content editor webpart in the form. Added the sample code snippet in question. – shoegal91 Dec 24 '19 at 5:16
0

Go to site settings->site permissions->check permission, check if the user have "Add and Customize Pages".

If not, edit the user permission level with "Add and Customize Pages" permission.

| improve this answer | |

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.