2

I have this Script that uses Hillbilly Tabify on SharePoint Online

<script  type="text/javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<link  type="text/css" rel="stylesheet" href="https://.sharepoint.com/sites/Sante-Securite/SiteAssets/JSJihen/jquery-ui.css" /> 
<script type="text/javascript" src="//code.jquery.com/ui/1.11.3/jquery-ui.js"></script> 

<script type="text/javascript" src="https://.sharepoint.com/sites/Sante-Securite/SiteAssets/JSJihen/jquery.HillbillyTabify.min.js"></script> 

<div id="HillbillyTabifyDiv"><ul id="HillbillyTabify"></ul></div>

<script type="text/javascript">

jQuery(document).ready(function($) {
    //the example below creates 3 tabs, you can create as many tabs as you'd like by adding additional objects.
    //"Title" is the title of the tab and "size" is the number of fields to show in that tab
    //If there are any remaining fields they will appear as normal below the tabs

    var tabInfo = [
        {title:"Informations sur la personne impliqu&eacute;e/bless&eacute;e",size:5},
        {title:"Information sur l'&eacute;v&egrave;nement",size:10},
        {title:"Premiers soins et traitements (&agrave; remplir si applicable)",size:7}
    ];

    HillbillyTabifyForms(tabInfo);

});

I want to restrict access of the 3rd tab only for certain persons by permission. How i can do it please?

2
  • IMHO This should be considered an acceptable question. HIllBilly Tabs was designed for SharePoint specifically, and relates to a specific requirements to retrieve the users groups from SharePoint. Jun 7, 2019 at 3:53
  • I agree with @JamesRandal, why is this on hold?
    – BigRaj
    Jun 9, 2019 at 4:11

1 Answer 1

2

If you are using a group to determine what users can see the 3rd tab, you can try something like this to selectively load the tab based on user being in a specific group:

jQuery(document).ready(function($) {

    var ctx = new SP.ClientContext.get_current();
    var web = ctx.get_web();
    var currentUser = web.get_currentUser();
    var userGroups = currentUser.get_groups();
    ctx.load(currentUser);
    ctx.load(userGroups);
    ctx.executeQueryAsync(
      function(){
        var groupEnum = userGroups.getEnumerator();
        var tabInfo = [
          {title:"Informations sur la personne impliqu&eacute;e/bless&eacute;e",size:5},
          {title:"Information sur l'&eacute;v&egrave;nement",size:10}
        ];
        while(groupEnum.moveNext()){
          var group = groupEnum.get_current();
          if(group.get_title() == "<Group Name As String>"){
            tabInfo.push({title:"Premiers soins et traitements (&agrave; remplir si applicable)",size:7});
            break;
          }
        }
        HillbillyTabifyForms(tabInfo);
      },
      function(sender, args){
        console.error(args.get_message());
      }
    )
});
4
  • Thank youuuu very much! It work :)
    – Jihen
    Jun 6, 2019 at 17:24
  • no problem at all :-)
    – BigRaj
    Jun 6, 2019 at 17:32
  • You're possibly already aware, but for the next person who comes along - This does not secure the data, only hides it. Someone would still be able to see the data if they modify the javascript in there browser, or access the list content through other means. Jun 7, 2019 at 3:56
  • BigRaj i remarked, when i'm connected with another user, the tab is hidden but the fields of this tab are Shown!
    – Jihen
    Jul 30, 2019 at 15:36

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