Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7439909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:46:25+00:00 2026-05-29T10:46:25+00:00

I’ve got the following Sharepoint problem: I’ve created a Ribbon Button, which says Read

  • 0

I’ve got the following Sharepoint problem: I’ve created a Ribbon Button, which says “Read Only”. When I am on a list, and check some items, I want to set those items to read only.
The ribbon button works great and when I am doing an alert or something, I get an answer. So this cannot be the problem. I did the following:

var listitem;
var roleAssgn;
var Assgn;
var selectedItems;

function readonly() {
    selectedItems = SP.ListOperation.Selection.getSelectedItems();
    var currentListGuid = SP.ListOperation.Selection.getSelectedList();

    var context = SP.ClientContext.get_current();
    var currentWeb = context.get_web();
    var currentList = currentWeb.get_lists().getById(currentListGuid);

     for (k in selectedItems) {
        listitem = currentList.getItemById(selectedItems[k].id);
        context.load(listitem, 'RoleAssignments');
        context.executeQueryAsync(Function.createDelegate(this, this.readonlyPerItem), Function.createDelegate(this, this.failed));
    }
}

function readonlyPerItem(sender, args) {
    var k;
    var Assgn;
    var r;
  context = SP.ClientContext.get_current();
  roleAssgn = listitem.get_roleAssignments();

  for(r in roleAssgn){
        Assgn = roleAssgn[r];
        alert("1");
        context.load(Assgn, 'RoleDefinitionBindings');
        alert("2");
        context.executeQueryAsync(Function.createDelegate(this, this.readonlyPerRoleA), Function.createDelegate(this, this.failed));
    }
}

function readonlyPerRoleA(sender, args) {
    var bindings = Assgn.get_roleDefinitionBindings();
    var member = Assgn.get_member();
}

function failed(sender, args) {
        alert("FAIL");
}

This works great until it gets to the alerts. Alert-1 is working, but not Alert-2. The Debugger says: The object does not support the property “get_$h”.
And that happens in the sp_runtime.js with:

SP.DataRetrievalWithExpressionString.$1Q_0(a.get_$h(),d)

I dont really see a problem. Is this a bug or is it just not possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:46:26+00:00Added an answer on May 29, 2026 at 10:46 am

    Ok, I used another way to do this and wanted to let you know, how it worked for me. I used a JS in the Ribbon Menu to call another website, which is just an empty site. I added the parameters (listguid, siteurl and the itemid’s comma-seperated).
    Then that site just prints an “True” or “False”. This response will be caught by my Ribbon JS and show some message if it worked or not. This is my Ribbon JS:

    <CustomAction
        Id="ReadOnlyButton"
        RegistrationId="101"
        RegistrationType="List"
        Location="CommandUI.Ribbon"
        Sequence="15"
        Rights="ManageLists"
        Title="Set Readonly">
        <CommandUIExtension>
          <CommandUIDefinitions>
            <CommandUIDefinition
              Location="Ribbon.Documents.Manage.Controls._children">
              <Button
                Id="Ribbon.Documents.ReadOnly"
                Command="ReadOnly"
                Sequence="15"
                Image16by16="/_layouts/1031/images/formatmap16x16.png"
                Image16by16Left="-80"
                Image16by16Top="-128"
                Image32by32="/_layouts/1031/images/formatmap32x32.png"
                Image32by32Left="-160"
                Image32by32Top="-256"
                Description="Read Only"
                LabelText="Read Only" 
                TemplateAlias="o1"/>
            </CommandUIDefinition>
          </CommandUIDefinitions>
          <CommandUIHandlers>
            <CommandUIHandler
             Command="ReadOnly"
             CommandAction="javascript:
               var nid;
               function getItemIds()
               {
                 var itemIds = '';
                 var items = SP.ListOperation.Selection.getSelectedItems();
                 var item;
                 for(var i in items)
                 {
                   item = items[i];
                   if(itemIds != '')
                   {
                     itemIds = itemIds + ',';
                   }
                   itemIds = itemIds + item.id;               
                 }
                 return itemIds;
               }
               function handleReadyStateChange()
               {
                 if (client.readyState == 4)
                 {
                   if (client.status == 200) 
                   {
                     SP.UI.Notify.removeNotification(nid);
                     if(client.responseText == 'True') {                  
                      nid = SP.UI.Status.addStatus('The Rights has been set successfully', '', true);
                      SP.UI.Status.setStatusPriColor(nid, 'green');
                     } else {
                      nid = SP.UI.Status.addStatus('Error while setting Rights', '', true);
                      SP.UI.Status.setStatusPriColor(nid, 'red');
                     }
    
                      window.setTimeout('SP.UI.Status.removeStatus(\'' + nid + '\')', 5000);
                   }
                 }
               }
               function invokeReadOnly()
               {
                 var itemLength = 0;
                 var params = 'itemids=' + getItemIds(); 
                 for (var i=0;i&lt;params.length;i++) { if (',' == params.substr(i,1)) { itemLength++; } } 
    
                 if(itemLength > 0) {
                  nid = SP.UI.Notify.addNotification('Rights set for ' + (itemLength +1) + ' elements...', true);
                 } else {
                  nid = SP.UI.Notify.addNotification('Set Rights...', true);
                 }
    
                 var site='{SiteUrl}'; 
                 var url = site + '/_layouts/ReadOnly.aspx?listId={ListId}';
                 client = null;
                 client = new XMLHttpRequest();
                 client.onreadystatechange =  handleReadyStateChange;
                 client.open('POST', url, true);         
                 client.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
                 client.setRequestHeader('Content-length', params.length);
                 client.send(params);
               }      
               invokeReadOnly();"
    
          EnabledScript="javascript:
               function enableReadOnly()
               {
                 var items = SP.ListOperation.Selection.getSelectedItems();
                 return (items.length > 0);
               }
               enableReadOnly();"/>
          </CommandUIHandlers>
        </CommandUIExtension>
      </CustomAction>
    

    And this is my site behind it (ReadOnly.aspx):

    protected void Page_Load(object sender, EventArgs e)
    {
        string itemidsAll = Page.Request["itemids"];
        string listId = Page.Request["listId"];
        bool set = true;
    
        if (!String.IsNullOrEmpty(itemidsAll))
        {
            string[] itemIds = itemidsAll.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            int item = 0;
    
            SPSite _site = null;
            SPListItem spitem = null;
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                _site = new SPSite(SPContext.Current.Site.ID);
            });
            using (SPWeb web = _site.OpenWeb())
            {
                web.AllowUnsafeUpdates = true;
                SPList doclib = SPContext.Current.Web.Lists.GetList(new Guid(listId), false);                
    
                foreach (string itemId in itemIds)
                {
                    if (Int32.TryParse(itemId, out item))
                    {
                        spitem = doclib.GetItemById(item);
                        set &= SetItem(spitem, SPContext.Current, ref _site);
                    }
                }
    
                web.AllowUnsafeUpdates = false;
            }
            _site.Dispose();
        }
    
        Response.Clear();
        Response.Write(set.ToString());
        Response.End();  
    }
    

    The SetItem-Method is for setting the Rights. You can use your own stuff there 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.