Isaac
asked on
SharePoint jquery group
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.
SDIfunctions.js
Any help would be much appreciated. Thanks!
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())
<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" />
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;
}
Any help would be much appreciated. Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.