SharePoint is a functional, feature-rich platform, but there is definitely room for improvement. In this article, I’ll cover some of the basic issues and solutions that you may run into when attempting to extend SharePoint with client-side scripting. It will primarily serve as a reference point for future articles where I would otherwise risk repeating myself.
@kiwidust Just used your DateExtension lib. I see that quarterhours and businessdays in the add method is not implemented. why in the docs?
To be fair I did implement the methods. I just implemented them terribly.
First off, the “quarterhours” (and “halfhours” as well) were mistakenly calculating quarter and half minutes, not hours. Simple fix for a really dumbass mistake. Unfortunately the second issue was even dumbassier.
You see I originally released the component – and kept releasing updates for it for over six years – with no actual code in the “businessdays” calculation for the add() method. It was just plain empty. Last February I got an email mentioning this and so I fixed it. Then, a scant two months later I published an older version of the component to GitHub that didn’t have it. A year later I get a tweet.
You should be able to recognize two things: 1) nobody uses this, and 2) I’m an idiot.
In any case the component has been corrected (again) and uploaded to GitHub.
SharePoint has many useful integration points with Microsoft Office out-of-the-box, but for truly deep integration you have to roll-up your sleeves and dig into some code. While there are multiple methods to do this, one of the most versatile is leveraging SharePoint’s many web services directly via Visual Basic for Applications. For those, like me, that lack SharePoint Designer access, this is often the only method available.
This method can be used in any application that supports VBA. This includes all the standard MS Office applications – Word, Excel and PowerPoint – but also other applications such as my favorite drawing suite, CorelDraw, or Autodesk AutoCAD. These examples were developed against SharePoint 2010 and MS Office 2010, but should also work in the 2007 and 2013 versions.
- Simple methods to add or remove events from SharePoint form elements.
- Simple methods to hide and show elements of SharePoint forms.
- Methods to simplify the calling and use of SharePoint web services and ready the data returned from them for use.
The library should be considered (very) beta but I am using it in a heavily trafficked production development. I’ve got lots of plans for this, as I’m in a position to do a lot of SharePoint development over the next few months or years (all without access to SharePoint Designer or any back-end support).
Comments, criticisms or suggestions are always welcome!
Those, like me, that put in the position of managing a SharePoint Team Site without SharePoint Designer access (or indeed without the ability to install development software of any kind) are forced to get creative sometimes. Leveraging the many rich (but annoying inscrutable) web services available offers a lot of interesting possibilities but adds significant challenges. Most people will start with getting data from lists.
The following components have been moved – feel free to fork ’em!
I’ll be maintaining the documentation here at DepressedPress.com, for now at least, and the examples will still be hosted at Comcast (as I’ve found no other viable options). I’m open to any other suggestions to make working with my stuff easier.
Way back in the history-times, in August of the year 2000, I authored an article detailing a technique that allowed for bi-directional communication between a server and a web browser without a page refresh. The technique was, if I do say so myself, pretty clever in a primitive, kludgy, clunky kind of way. I have no idea if I was really the “first” to come up with this but I do know that the rise of standardized AJAX a few short years later completely and deservedly eclipsed it.
Using a GIF as a Data Pipe
What I’ve recently realized is that a lot of traffic still points to that article. I, in fact, get nearly as many 404 errors for people looking for this article as I do legitimate hits to the site (“popular” I am not). It’s listed in the Wikipedia article on Remote Scripting and in many blogs, forums and resource sites. For the curious various versions of it are available on the Internet Archive.
Now it’s nothing more than a weird little historical artifact that I’ll keep here on the digital mantle for posterity.
I need to simulate the MS Excel networkdays() function. Excel would count 10th Jan 2013 midnight to 15th Jan 2013 midnight as 4 working days (6 days in total) but DP_DateExtension.js does not count the 10th so outputs 3 working days (5 total).
The Excel NetworkDays() function returns “business days” (removing Saturday and Sunday and optionally holidays from the calculation). In this case passing the function January 10th (a Thursday) to January 15 (a Tuesday) results in “4”. This makes it clear that Excel is doing this calculation inclusively by date and obviously not from “midnight to midnight”.
[I was reminded of my favorite “Point-haired boss” anecdote today. Thought some of you might be able to relate.]
I explained how the new financial goal planning system we developed dynamically reacted to user data during a questionnaire to both dramatically improve performance and customize presentation zones with contextual, meaningful information during an interaction. Income bracket, number of dependents, current savings, etc – it would all feed into a dynamic, context-sensitive system that presented tailored information and products. Initial human factors work indicated orders-of-magnitude increases in user acceptance and confidence in the system.
After a 30 minute presentation about the business opportunities the new technique presented the lead executive in the room thought long and hard, nodded and then said “Can we make it blue?“
// Set first day of week to Monday ("1")
Date.FirstDayOfWeek = 1
// Create a new date
CurDate = new Date();
// Perform some date math
RoundedWeek = CurDate.round("weeks");
FloorWeek = CurDate.floor("weeks")
CeilWeek = CurDate.ceil("weeks")
Personally I’ve not needed to leverage this yet, but I can definitely see it coming in handy.