Introduction

This article introduces how to find or check a user group and filter Lookup column depending on group permission in SharePoint 2010 using spservices (jQuery).

Detailed Procedure

Step 1

Create a SharePoint site.

Step 2

Create a user group and add one user to the group, for example I have a user group Management and user Laxman vyavahare as shown bellow:

Creating User Group in SharePoint Site

Step 3

Create two lists, namely Status and FilterStatus.

Step 4

Click on the Add new item link button and see the lookup column; here you can see the following 4 options:

Filter Status

But the Management user group has only access for Approval and Rejection so how I can hide (or by filter lookup column) open and close status from the management user group.

Solution

Step 5

Open the FilterStatus list in the Designer and add the following lines of code on NewForm.aspx or EditForm.aspx page under the <script> tag as below:

  1. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  2. <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/0.7.1a/jquery.SPServices-0.7.1a.min.js"></script>
  3. <script type="text/javascript">
  4. $(document).ready(function () {
  5. alert('hi');
  6. $().SPServices({
  7. operation: "GetGroupCollectionFromUser",
  8. userLoginName: $().SPServices.SPGetCurrentUser(),
  9. async: false,
  10. completefunc: function (xData, Status) {
  11. if ($(xData.responseXML).find("Group[Name='Management']").length == 1)
  12. {
  13. alert("login inside of the Group user");
  14. $().SPServices.SPFilterDropdown({
  15. relationshipList: "Status",
  16. relationshipListColumn: "Title",
  17. columnName: "FilterStatus",
  18. CAMLQuery: "<Neq><FieldRef Name='Active' /><Value Type='Boolean'>Yes</Value></Neq>",
  19. completefunc: null,
  20. debug: false
  21. });
  22. }
  23. else {
  24. alert("login outside of the Group user");
  25. }
  26. }
  27. }); /*close().SPServices({ */
  28. }); /* close (document).ready(function() { */
  29. </script>

Step 6

Save both of the .aspx pages of the list and close the designer.

Step 7

Then open your FiltrStatus list and see the effect.

New Filter Status

Now the Management group has access for Approval and Rejection.