jQuery Library for SharePoint Web Services (SPServices) 2014.01 Released

SPServicesHot on the heels of the short-lived SPServices 2013.02 and it’s younger, wiser sibling 2013.02a, comes SPServices 2014.01. I wanted to do a new release with some cool new functionality, but Microsoft really forced my hand with some changes to title attributes on some column types. (See: Office 365 Update Changes ‘Display Name’ on Required Fields)

I recommend jQuery 1.10.x with this release. Even if you are a happy user of an older release of SPServices, I’d recommend upgrading to this release.

The headlines for this release:

  • Fix for the ” Required Field” change to column titles noted above on Office365 buildversion 16.0.2510.1204 (or thereabouts) and above and SharePoint 2010 with the December 2013 CU
  • New function SPGetListItemsJson
  • Exposed existing private function DropdownCtl as public function SPDropdownCtl
  • New objectType for SPXmlToJson: JSON
  • Case insensitive query string values with $().SPServices.SPGetQueryString
  • Added ClaimRelease operation to the Workflow Web Service

The SPGetListItemsJson function is pretty cool, if I do say so myself. When I fixed the operation GetListItemChangesSinceToken in 2013.02, I saw the possibility for an auto-conversion of the returned data to JSON with only one SOAP call. Because GetListItemChangesSinceToken returns both the list schema and the data, I’m able to parse the schema and return the data as JSON using SPXmlToJson. You can also pass in your own mappingOverrides if you need to.

GetListItemChangesSinceToken is also cool because it allows you to retrieve content deltas by passing in the old changeToken, and SPGetListItemsJson returns the changeToken and also accepts it for future calls. This is great support for the types of Single Page Applications I discuss in my ongoing blog series Single-Page Applications (SPAs) in SharePoint Using SPServices.

While I was building SPGetListItemsJson, I was working on a client project where we stored JSON as text in a Multiple lines of text column. To facilitate conversion of that data to internal JSON, I added an objectType to SPXmlToJson of “JSON”. This allows us to request automatic conversion of text-based JSON data to internally represented data simply by specify the JSON objectType in a mappingOverride. (The function uses jQuery’s $.parseJSON.)

With the kerfuffle about the Office 365 Update Changes ‘Display Name’ on Required Fields and the attendant fixes I needed to do in SPServices, I decided to make the SPDropdownCtl function I’ve been using for years public.  It’s not for the faint of heart, as it passes back a variable object depending on the type of “dropdown”, but it should help some people in building their own applications.

As usual, there are also a number of additional changes to fix existing bugs or improve efficiency (yes, I’m still able to improve on my old code, and I expect that will continue).

You can see the full list of enhancements and improvements on the download page. Note the link to the Issue Tracker items for this release. For posterity, here are links to the release notes showing all the fixes and improvements from the Issue Tracker on Codeplex.

New Functionality

Alpha Issue Tracker Item Function Description
ALPHA1 10216 $().SPServices.SPGetListItemsJson New Function: SPGetListItemsJson
ALPHA1 10221 $().SPXmlToJson Add new objectType to SPXmlToJson for text columns containing JSON
ALPHA1 10218 $().SPXmlToJson Add sparse parameter to SPXmlToJson
ALPHA1 10195 $().SPServices.SPGetQueryString Case insensitive SPGetQueryString?
ALPHA3 10229 $().SPServices.SPDropdownCtl Make DropdownCtl Function Public
ALPHA4 10230 $().SPServices.SPDropdownCtl Return optHid input element in SPServices.SPDropdownCtl

New Operations

Alpha Web Service Operation Options MSDN Documentation Issue Tracker Item
ALPHA2 Workflow ClaimRelease item, taskId, listId, fClaim http://msdn.microsoft.com/en-us/library/workflow.workflow.claimreleasetask(v=office.12).aspx 10222

Bug Fixes and Efficiency

Alpha Issue Tracker Item Function Description
ALPHA1 10211 $().SPServices.SPGetQueryString LMenuBaseUrl is undefined
ALPHA1 10192 $().SPServices.SPGetQueryString DeleteWeb needs_SOAPAction Value Incorrect
ALPHA1-2 10219 $().SPServices.SPXmlToJson Various Fixes to SPXmlToJSON
ALPHA2 10224 $().SPServices.SPCascadeDropdowns ParentObject Null in $.fn.SPServices.SPCascadeDropdowns
ALPHA2 10225 $().SPServices.SPXmlToJson SPXmlToJson – Fix Date/Time Conversion
ALPHA2 10226 $().SPServices.SPCascadeDropdowns Cascade Dropdowns Do not work if Fields Are Required
ALPHA4 10231 $().SPServices.SPCascadeDropdowns Title Changed for Required Fields after CU for Sharepoint 2010
BETA2 10238 $().SPServices.SPDisplayRelatedInfo SPDisplayRelatedInfo not working in SPServices 2014.01
BETA2 10236 NA Replace .attr(“value”) usage with .val()
BETA2 10235 $().SPServices.SPRequireUnique SPRequireUnique bug getting entered value

Similar Posts

11 Comments

  1. Does this work with Sharepoint 2010? I am using SPServices-0.7.2 with Sharepoint 2010 and JQuery 1.8.3 and wanted to upgrade to the latest version of JQuery and SPServices…Can I upgrade to this version? Anything that I need to be mindful of? Thank you so much for all your efforts.

  2. Hi Marc,

    Good day!

    May i seek your assistance about my code below? I have no problem on SharePoint 2007 using this code but after i applied to SharePoint 2013, the script doesnt work. i expected to show the current site using alert but after i click the save button. Any idea what is wrong please? Thanks.

    $(document).ready(function() 
    {
        $("input[Title='Numbering']").attr('disabled','true');
    
    });
    
    function PreSaveAction() 
    { 
      var num;
      var itemCount; 
      alert($().SPServices.SPGetCurrentSite());
    
      $().SPServices({
        operation: "GetListItems",
        async: false,
        listName: "TOTL CA 2014",
        CAMLViewFields: "", CAMLRowLimit: 1, CAMLQuery: "",
    
        completefunc: function (xData, Status) {
                   $(xData.responseXML).SPFilterNode("rs:data").each(function() {    
                   itemCount = $(this).attr("ItemCount");
                                                                   });
                   if(itemCount == "0")
                   {
                       alert("0");     
    		   $("input[Title='Numbering']").value("1");
                   }
                   else
                   {
                       alert(itemCount);     
                       $(xData.responseXML).SPFilterNode("z:row").each(function() {
    		   $("input[Title='Numbering']").value(parseInt($(this).attr("ows_Numbering")) + 1);
                                                                     });
                   } 
                                               }
                   });
      return true;
    }
    
    1. Kilua:

      Can you please post this in the SPServices discussions on Codeplex? It’s much easier to have a longer discussion there and you can also format your code with the editing tools.

      M.

    2. Kilua:

      It’s been a while since you posted this, but script that works in 2007 ought to work basically the same in 2013. My guess is that you are missing a semi-colon or something (I can’t spot it). Are you sure the script is even loading and running? A little debugging ought to get you there.

      M.

    1. Alex:

      I can’t realistically test against every version of jQuery and SharePoint. But I can’t recall any reports of things *not* working with 1.7.2. I definitely would recommend that you upgrade to a more recent version, though. There are benefits way beyond making SPServices work better. Also, you can load your own instance of jQuery if need be, using $.noConflict to avoid difficulties.

      M.

  3. Hello Marc,

    When upgrading to SP2016/19 from SP2013, the SPGetListItemsJson call doesn’t fire for anonymous user and prompts to login. The function call on 2013 has no issue though. I appreciate if you can shed a light. Thank you!

    Mojgan

    1. @Mojgan:

      SPServices has always relied on the signed in user’s identity. I’m suprised it would have worked with anonymous users in SP2013.

      In any case, I’d suggest switching your calls to REST at this point. While the SOAP services are still there in SP2010 and even SPO, they have been deprecated for a number of years now.

      M.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.