jQuery Library for SharePoint Web Services v0.4.6 Released

Today I released v0.4.6 of my jQuery Library for SharePoint Web Services.  This version was fun to work on because I’ve got quite a few people out there in the world (California, North Carolina, Sweden) using the library actively, so we were able to work together pretty much real time to get enhancements and bug fixes into the library together.  This was also the first release where I decided to keep a current alpha version posted on Codeplex while I was doing the work.  This was rewarding because there was a real feedback loop going on.  I think this is a better way to go in the future, so watch for more alpha versions you can kick the tires on for me (actually for all of us).

This release has two really nice enhancements:

  • SPCascadeDropdowns now works with multi-select child columns. This was the most requested enhancements over the last few months, and to be honest I dragged my feet on it.  The controls that SharePoint uses for multi-select choices are just plain complicated.  There’s also a whole pile of JavaScript which sites behind it all (groupeditempicker.js) that took some time to dig through.  The good news is that I was able to take advantage of those “native” JavaScript functions and write less of my own code.

Multi-Select Example

  • Both SPCascadeDropdowns and SPDisplayRelatedInfo now have a new CAMLQuery option which allows you to specify additional filters on the relationshipList.  You specify this as an additional CAML fragment which is then <And>ed with the filters which the library uses to grab the allowable values.  For example, the CAMLQuery option can contain a CAML fragment like:
CAMLQuery: "<Gt><FieldRef Name='ID'/><Value Type='Counter'>1</Value></Gt>"

or

CAMLQuery: "<Eq><FieldRef Name='Status'/><Value Type='Text'>Active</Value></Eq>"

Additionally, the $().SPServices.SPCascadeDropdowns and $().SPServices.SPSPDisplayRelatedInfo functions are now *much* more efficient.  As part of the refactoring I did in v0.4.5, there were some unnecessary Web Services calls happening.  With this efficiency change, there are no unneeded calls, so the dropdowns ought to behave almost as fast as they would without the functions sitting behind them.Of course there are some bug fixes as well.

Release Notes

New Functionality

Issue Tracker Item Function Operation Description
NA $().SPServices.SPCascadeDropdowns NA SPCascadeDropdowns now works with multi-select child columns.
NA $().SPServices.SPCascadeDropdowns and $().SPServices.SPSPDisplayRelatedInfo NA Added a new option on SPCascadeDropdowns and SPDisplayRelatedInfo for an additional filter, specified as a CAML fragment which is inserted into the existing filter. See the documentation for details.

 New Operations

Web Service Operation Options MSDN Documentation
Lists UpdateList listName, listProperties, newFields, updateFields, deleteFields, listVersion Lists.UpdateList Method

 Bug Fixes and Efficiency

Issue Tracker Item Function Operation Description
NA $().SPServices.SPCascadeDropdowns and $().SPServices.SPSPDisplayRelatedInfo NA Added an additional check for column value changes within the cascadeDropdown and showRelated private functions to reduce unnecessary Web Service calls. This change makes both functions considerably more efficient and therefore faster.
NA $().SPServices.SPCascadeDropdowns NA Fixed an issue in SPCascadeDropdowns when a child column is a Lookup to a Lookup column, and therefore displayed option values in the format ‘ID;#Value’, e.g., 1;#Massachusetts.
NA All list-based functions NA Tighter code to find z:row elements in XML using the selector: find(“[nodeName=z:row]”) based on a nice trick from Kevin Whinnery.
NA $().SPServices.SPCascadeDropdowns NA Fixed an issue in SPCascadeDropdowns when a parentColumn has multiple childColumns which caused only the first childColumn to be filtered.
NA listNameFromUrl() private function NA More reliable listNameFromUrl() using GetListCollection. The prior version was failing if the list had been renamed.
NA $().SPServices. SPRequireUnique NA Fixed a bug in SPRequireUnique where both values for duplicateAction (0 = warn, 1 = prevent) were acting like prevent. Also made the <span> which contains the messages unique per column in case the function is used more than once on the form.

7 Comments

  1. I’ve tried the SPRedirectWithID function. It seems that it could not work with Sharepoint 2010. Any plan for this library also work with Sharepoint 2010?

    Reply
    • I don’t have a solid plan at this point for SharePoint 2010 with the library. I know that some of the functions won’t really be necessary (because there is analogous functionality in 2010), but the basic Web Services stuff should work the same.

      You’re the first person who’s asked other than hypothetically!

      M.

      Reply
    • Winson:

      I haven’t done any testing of my library with SharePoint 2010 yet. It’s possible that the $().SPServices.SPRedirectWithID function will work, but I’m guessing it won’t as there are bound to have been some changes to the page structures that the function uses. Give it a try and let me know whether it works or not!

      M.

      Reply
  2. Hi,

    I have change the SPRedirectWithID like this:

    if(vals[“ID”] == undefined) {

    newID = parseInt(lastID) + 1;
    newID = newID + ‘ ‘; // it will go to next item ID & change the newID as String


    $().find(“form[name=’aspnetForm’]”).each(function() {

    var SPurl = location.href.substring(0,location.href.lastIndexOf(“/”));

    var thisRedirectUrl = (typeof vals[“RedirectURL”] == “string”) ? vals[“RedirectURL”] : opt.redirectUrl;
    var newAction = SPurl + “/” + thisRedirectUrl + “?ID=” + newID;
    $(this).attr(“action”, newAction);

    The original url: http://servername/Lists/listname/newform.aspx
    The newAction will become: http://servername/Lists/listname/RedirectURL?ID=newID

    However, the aspnetForm action does not work in SP2010! Please Help! The last sentence does not work (change the action attribute).

    The SPGetLastItemID function has following problem:

    If all the list item had been removed, the SPGetLastItemID will return value of “1” which is not the actual last item ID!

    Reply
    • Winson:

      Looks like you are getting there. As I said, I haven’t done *ANY* testing with SharePoint 2010, so you’re on your own there for now, though I plan to look at it sometime.

      It’s not enough to just add 1 to the “lastID”. Others could be adding items in the interim. Also, I’m not sure how all items could have been removed when your user will have just committed one. You want to use the ID for that last committed item by this user, which is what I’m using the Web Services to find.

      I’d appreciate it if you could post your findings on the Codeplex site Discussions so that I can track against it there. It will help me when I get to the point of testing (and probably reconfiguring) this for SharePoint 2010.

      M.

      Reply

Have a thought or opinion?