Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

New Post: SharePoint Hide a list field based on user group

$
0
0
I am able to solve the issue and i am getting results.

I need one help.We have a production Protal where we are adding NT AUTHORITY\authenticated users so that all authenticated users can access the protal.

I use the below code to hide the columns based on User Group.

But the problem with the below mentioned code is let us say a user named A( NT AUTHORITY\authenticated users) is not part of ADG Members,ADG Owners and PAG Members then the GetGroupCollectionFromUser method is not going to return any results for me since user A is not in any one of the above mentioned groups.

I want to hide the columns for all the NT AUTHORITY\authenticated users.How to get the status from the completefunc: function(xData, Status) method.

So if the status is null or empty so that i can decide the user is a part of NT AUTHORITY\authenticated users.

Is any other way to overcome this issue.


<asp:Content ContentPlaceHolderId="PlaceHolderBodyAreaClass" runat="server">

<script type="text/javascript" src="http://knowledge.bankofamerica.com/SiteCollectionDocuments/js/jquery-1.10.2.min.js">>
<script type="text/javascript" language="javascript" src="
http://knowledge.bankofamerica.com/SiteCollectionDocuments/js/jquery.SPServices-0.7.2.min.js">>

<script src="
http://knowledge.bankofamerica.com/SiteCollectionDocuments/jPoint-0.8/jPointLoader.js">>
<script src="
http://knowledge.bankofamerica.com/SiteCollectionDocuments/jPoint-0.8/jPoint-0.8.min.js">>

<script language="javascript" type="text/javascript">

$(document).ready( function ()
{
               alert("Test");

                var isUserOnly = false; //User group member only
                var isModerator= false;
                var isAdmin=false;
                var isPAG=false;
                var MODERATORGROUP = "ADG Members"; // SPGroup named “Moderators”
                var ADMINGROUP = "ADG Owners";  // SPGroup named “Admin”
                var PAGGROUP = "PAG Members";  // SPGroup named “PAG Members”
                var NTAuthenticatedGROUP = "PAG Members";  // SPGroup named “PAG Members”
                var username;

                $().SPServices
                ({
                  operation: "GetGroupCollectionFromUser", //Calling GetGroupCollectionFromUser.asmx web service
                  userLoginName: $().SPServices.SPGetCurrentUser(), //Calling Current User
                  async: false,
          completefunc: function(xData, Status)
                  {                         

                                    $(xData.responseXML).find("Groups").each(function() //Retrieving the values from Group method of Web Service
                                    {
                                        //Parsing through all the groups the current user belongs to

                                         $(this).find("Group").each(function()  
                                         {

                    //Checking whether Current User belongs to Admin Group                          

                   alert($(xData.responseXML));

                     if(($(this).attr("Name").toLowerCase() === ADMINGROUP.toLowerCase()))
                      {
                          isAdmin = true;
                      }
                    //Checking whether Current User belongs to Moderators Group
                      else if(($(this).attr("Name").toLowerCase() === MODERATORGROUP.toLowerCase()))
                      {
                        isModerator=true; 
                      }

                    //Checking whether Current User belongs to P&G Group

                      else if(($(this).attr("Name").toLowerCase() === PAGGROUP.toLowerCase()))
                      {
                        isPAG=true;

                      }

                    //If Current User does not belong to Moderators or Admin, then definitely a normal user
                      else
                       {
                         isUserOnly=true;
                       }

                      });
                                    });
                     }

               });
              // Closing SPServices Method

Viewing all articles
Browse latest Browse all 6517

Trending Articles



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