SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to find out if logged in user belongs to a specific sharepoint group (2010). I am using below code to get it. but getting javascript error as 'SPServices is null or not an object'.

    <script src="/sites/XXX/XXXX/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="/sites/XXX/XXXX/jquery.SPServices-0.7.1a.min.js" type="text/javascript"></script>
<script type="text/javascript">

$(document).ready(function () {

            operation: "GetGroupCollectionFromUser",
            userLoginName: $().SPServices.SPGetCurrentUser(),
            async: false,
            completefunc: function (xData, Status) {

if ($(xData.responseXML).find("Group[Name='Site Admin']").length == 1) {
                    alert("User in a group");
alert ("User is not in group");




So many are saying the error occurs if jquery files not referenced properly. I stored the files in a doc library and referencing it in javascript.

share|improve this question
do I have to add _spBodyOnLoadFunctionNames.push(); also at the end? – Srikanth Jan 29 '13 at 12:56
Try absolutely referencing them to ensure they are loading properly. What is loading this script? is it a js file you have stored and are referencing in a CEWP or is this baked into a page layout/master page? – Eric Alexander Jan 29 '13 at 16:39

Ì had this issue when loading jQuery on the page and later adding jQuery to the master page for the site.

It can be useful to use the web debugger in Chrome to view exactly which scripts are being loaded.

  1. Press 'F12' to launch the tool
  2. Open the 'Resources' Tab
  3. Expand the frames then the page folder
  4. The scripts folder will show all the currently loaded scripts.

Check here to see if you have any duplication.

share|improve this answer
up vote 0 down vote accepted

I just kept the Content editor webpart at bottom in the webpart zone. that's it. it is working fine now.

share|improve this answer

Here is an example that shows how to reference the js files present in Document Library.

<script type="text/javascript" src="/Shared%20Documents/JS/jquery.min.js"></script>
<script type="text/javascript" language="javascript" src="/Shared%20Documents/JS/jquery.SPServices-0.6.2.min.js"></script>

Here I perform a somewhat similar task:

share|improve this answer
This is not correct. This example assumes that his JavaScript assets are in the root site of the web application, which is not the case given the example paths in the original post. There is nothing wrong with the way Srikanth has loaded his JavaScript. – webdes03 Jan 29 '13 at 13:47
I was just showing an example based on his comment: "So many are saying the error occurs if jquery files not referenced properly. I stored the files in a doc library and referencing it in javascript." – Nadeem Yousuf Jan 29 '13 at 13:52
@webdes03 Do you have any other alternate solution to find out user group? – Srikanth Jan 29 '13 at 14:02
@Srikanth, Since you are in SP 2010, you can also try ECMA script Client Object model. – Nadeem Yousuf Jan 29 '13 at 14:09
@NadeemYousuf Ohh. I tried the solution that you provided in a link but still getting the error (I did not reference as you did, I keep my original as mentioned in question). – Srikanth Jan 29 '13 at 14:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.