Pages

7 Oct 2016

Hide Attachments from specific SharePoint Group

 <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js' type="text/javascript">  
 </script>  
 <script type="text/javascript">  
   $(function() {  
     $.ajax({  
       url: "/_api/web/currentUser?$select=Groups/Title&$expand=Groups",  
       method: "GET",  
       headers: {  
         "Accept": "application/json; odata=verbose"  
       },  
       success: function(data) {  
         for (var k = 0; k < data.d.Groups.results.length; k++) {  
           var groupName = data.d.Groups.results[k].Title;  
           if (groupName == 'OECTA EXEC GL') {  
             $("[scriptclass='SharePointFileAttachmentCollection'], [scriptclass='SharePointFileAttachmentContainer']").hide();  
           }  
         }  
       },  
       error: function(data) {  
         console.log(data);  
       }  
     });  
   });  
 </script>  

No comments:

Post a Comment