Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SharePoint jquery group

Posted on 2013-01-14
1
Medium Priority
?
631 Views
Last Modified: 2013-01-16
Hello All,

The platform is SharePoint 2007.

I am trying to use jquery to link a column based on the group the user is in.  If the user in the "ACC" group, I want to link the title column and if they are not, i don't want it linked.

The code below works, sort of.  If my function(GetGroupOfUser()) returns true, it links the column but if it's false, I get the following runtime error" 'boolVal' is undefined.



<script type="text/javascript" language="javascript" src="http://moss2007vm:10712/sdimetrics/js%20Assets/SDIfunctions.js"></script>
<script type="text/javascript" language="javascript" src="http://moss2007vm:10712/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" language="javascript" src="http://moss2007vm:10712/js/jquery.SPServices-0.7.2.min.js"></script>


<script type="text/javascript" language="javascript">
$(document).ready(function() {
//var getBoolVal= GetGroupOfUser();
var liHtml = "<table width=100% border=1><th><td>Title</td><td>ID</td></th>";

var isTrue = [b]GetGroupOfUser()[/b];
if(isTrue)
{
alert("True");
}
else
{
alert("False");
}
  $().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "SDIMetrics",
    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='MAJCOM' /><FieldRef Name='ID' /></ViewFields>",
    completefunc: function (xData, Status) {
          $(xData.responseXML).SPFilterNode("z:row").each(function() {
if(isTrue) {
alert("Provide a link");
    liHtml += "<tr><td><a href='www.google.com'>"+$(this).attr("ows_Title") +"</a></td><td>"+$(this).attr("ows_ID") +"</td></tr>";
       }
else {
alert("no link needed");
    liHtml += "<tr><td>"+$(this).attr("ows_Title") +"</td><td>"+$(this).attr("ows_ID") +"</td></tr>";
}

//alert(liHtml);
      });
liHtml += "</table>";
$("#tasksUL").append(liHtml);
    }
  });
  
});
</script>
<label id="tasksUL" />

Open in new window





SDIfunctions.js
function GetGroupOfUser(){   
var boolval = false;
var curUser = $().SPServices.SPGetCurrentUser();
alert(curUser);
$().SPServices({
      operation: "GetGroupCollectionFromUser",
      userLoginName: $().SPServices.SPGetCurrentUser(),
      async: false,
      completefunc: function(xData, Status) {   
        if($(xData.responseXML).find("Group[Name='ACC']").length == 1) {
alert("Hello.  I am in this group.");
		  boolVal = true;
        }              

      }

   }); /*close().SPServices */ 
return boolVal; 
}

Open in new window



Any help would be much appreciated.  Thanks!
0
Comment
Question by:Isaac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 2000 total points
ID: 38775389
Hi,

just a simple typo - Javascript is cASe sensitive ;-)))

You return boolVal, but your variable in the GetGroupOfUser function is named
boolval (lowercase V).

Just change line 2 in
SDIfunctions.js to
var boolVal = false;

Open in new window

and it should work.

HTH
Rainer
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
When using a search centre, I'm going to show you how to configure Sharepoint's search to only return results from the current site collection. Very useful when using Office 365 with multiple site collections.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question