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.

  • do I have to add _spBodyOnLoadFunctionNames.push(); also at the end?
    – Srikanth
    Jan 29, 2013 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? Jan 29, 2013 at 16:39

4 Answers 4


Ì 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.

  • And what if you have to add it to both? I ran into where I was loading SPServices on the master, but in the context of an HTML Form Editor webpart, it was not being recognized. Tried adding the reference to SPServices even there but still got the same error as the OP. Telling someone to "check their script loading" doesn't tell them how to resolve where/how to load them.
    – vapcguy
    Mar 10, 2016 at 22:28
  • The OP was unsure if the library was being referenced properly, the above steps will allow you to confirm that your reference is working and the library is loading.
    – liamog
    Mar 11, 2016 at 13:11
  • And I'm telling you that, no, it doesn't, because I tried it. It found my master page reference to SPServices, but I still had an error like it wasn't loading. The master page referred to a different, known working one than I ultimately referenced in my webpart. It wasn't until I referenced another location (and replaced that file with a known good one) within my webpart that it started working. So tips like this don't always work - they can find the resources just fine, they don't tell you they're actually being used in the context of the code that is being run - ESPECIALLY within webparts.
    – vapcguy
    Mar 30, 2016 at 14:17

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

  • Vague answer. Doing nothing but leaving things as-is doesn't magically fix an issue.
    – vapcguy
    Mar 10, 2016 at 23:40

Had a similar issue. So what I found was I could add the reference inside my HTML Form Editor web part - I did this like this:

<script src="../SiteAssets/js/jquery.SPServices-0.7.2.min.js" type="text/javascript"></script>

but it would give me the error like the OP found at just this line of code:

var userName = $().SPServices.SPGetCurrentUser();

as if it was not loading SPServices. There was another SPServices file (same version, also minified) on another site where it was working correctly, so I replaced my version with that one, and it started working after I refreshed my page. Perhaps it was corrupted or something had happened when I downloaded my original SPServices file, or because I don't remember where I downloaded it from, if it was some GitHub or other similar place I go to occasionally, it could have been modified in a way that made it unserviceable. Guess that's a lesson to me that I need to be sure of where my files are coming from and that I get stable versions...

There are a few later versions than this that I don't have time to try, but this has the stable version of jquery.SPServices-0.7.2.min.js that I can vouch works: https://spservices.codeplex.com/releases/view/81401


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: http://sharepointnadeem.blogspot.in/2011/09/hide-sharepoint-list-field-based-on.html

  • 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, 2013 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." Jan 29, 2013 at 13:52
  • @webdes03 Do you have any other alternate solution to find out user group?
    – Srikanth
    Jan 29, 2013 at 14:02
  • @Srikanth, Since you are in SP 2010, you can also try ECMA script Client Object model. Jan 29, 2013 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, 2013 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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