Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Script Not Working for User With Read Permissions

$
0
0

I have a workflow that sends emails out. When a user receives the email, there is a hyperlink called Review. When user clicks on Review, the  value of the column called ReviewStatus on the Improvement List  will be changed to Requested. I have a script below that handles this on a Content Editor Web Part:

<script language="javascript" type="text/javascript">
_spBodyOnLoadFunctionNames.push("getSetListItem");
        var listItem;
        var list;
        var clientContext;
        var siteUrl = "https://contoso.com/process/";
        function getSetListItem() {
            this.clientContext = new SP.ClientContext(siteUrl);
            if (this.clientContext != undefined && clientContext != null) {
                var webSite = clientContext.get_web();
                var itemID = parseInt(GetUrlKeyValue('ID'));
                this.list = webSite.get_lists().getByTitle("Improvement");
                this.listItem = list.getItemById(itemID);
                clientContext.load(this.listItem);
                this.clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadSuccess),
Function.createDelegate(this, this.OnLoadFailed));
            }
        }
        function OnLoadSuccess(sender, args) {
            var value = this.listItem.get_item("ReviewStatus");
            this.listItem.set_item("ReviewStatus", "Requested");
            this.listItem.update();
            this.clientContext.load(this.listItem);
            this.clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadSuccess1),
Function.createDelegate(this, this.OnLoadFailed));
        }
        function OnLoadSuccess1(sender, args) {
            alert(this.listItem.get_item("ReviewStatus"));
        }
        function OnLoadFailed(sender, args) {
            alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
        }</script>

The above works for me but I have Site Col Admin permissions. When a user with Read permissions clicks on the hyperlink it takes them to the page where the CEWP is and they get the below message:

I know it's permissions but what can I do to make it work for users who doesn't have the permissions? By the way, the client wants to keep the permissions to Read Only for users so there's nothing I can do about that.

Any help is appreciated.






Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>