Editing The SharePoint List Item Menu (Part 3: Other Uses)

Date:November 18th, 2010 Author: Tags: , , , , ,
Category: General, SharePoint Development, SharePoint Ideas, Training Comments:4 ;

In previous posts I’ve used the “Open in new window” function to illustrate the two different methods of adding to the List Item menu, or Edit Control Block (ECB) to use its catchier name.

Part 1 covered the CustomAction element; the developer-leaning Visual Studio method. Part 2 avoided any kind of dedicated program by doing the same directly in SharePoint using Javascript in a Content Editor Web Part (CEWP); for power users or those with software commitment issues.

In this section I’ll be looking at some more interesting, and possibly useful, extra options to illustrate the potential of these kinds of enhancements. These can also be used as stubs to produce more complex functionality along the same lines.

I’ve purposefully kept these changes low-touch (avoiding AJAX libraries for example), to make them quick to try out without installing any additional dependencies.

In each example I’ll give a snippet of code for using a CustomAction or Javascript; these will be brief, as they assume you’ve read my earlier posts.

E-mail a task

This example adds a link that pre-populates a new e-mail with some information from the selected task. It uses the good old ’mailto:’ to open the default mail program for the client machine. If you don’t have a default mail client then, well, it won’t (harsh but fair).

This can be used as a quick way to create nagging e-mails for task owners, or to highlight tasks that may be of interest to others.

menuemailemail

To add this option using Javascript, add the following to a CEWP:

<script type="text/javascript">
function getMailTo (ID)
{
var taskTitleLink = document.getElementById(ID).firstChild;
var mailTo = 'mailto:?subject=';
mailTo += encodeURIComponent(taskTitleLink.innerHTML);
mailTo += '&body=';
mailTo += encodeURIComponent('An intriguing task...\n\nTitle: ' + taskTitleLink.innerHTML + '\n');
mailTo += encodeURIComponent('Link: ' + taskTitleLink.getAttribute('href'));
return mailTo;
}

function Custom_AddListMenuItems(m, ctx)
{
CAMOpt(m,’E-mail’,’window.location=getMailTo(‘ + currentItemID+ ‘);’,’/_layouts/images/EMAILPST.PNG’);
return false;
}
</script>

To produce the same result using a CustomAction, using almost the same Javascript in the link; the following UrlAction should be used:

<UrlAction Url="javascript:window.location='mailto:?subject='+encodeURIComponent(document.getElementById({ItemId}).firstChild.innerHTML)+'&amp;body='+encodeURIComponent('An intriguing task...\n\nTitle: '+document.getElementById({ItemId}).firstChild.innerHTML+'\n')+encodeURIComponent('Link: '+document.getElementById({ItemId}).firstChild.getAttribute('href'));"/>

The differences between the two (other than the infrastructure used) are as follows:

  1. UrlActions are ugly not amenable to declaring Javascript functions in an readable way.
  2. URL in an UrlAction is  wrapped in a Javascript function (STSNavigate) when rendered in the OnMenuClick event attribute, so it needs the javascript: prefix to use such. The Javascript version is put in the same event attribute, but without the wrapping function no prefix is needed.
  3. currentItemId and {ItemId} both get the current List Item’s ID in their own contexts.

The code in both of the above examples take advantage of the fact the Title and link are within the div that shares this item’s ID. Using this method limits the amount of information we can get our hands on. We can get a little more using GetAttributeFromItemTable, but to get all the information we’d have to use some more contrived methods.

Shorten an item linkmenushorten

This option opens a new window to tinyurl’s site with the task’s abbreviated link posted through. If you’re using an earlier version of Flash than 10 (rather you than me) it’ll even put it in the clipboard for you.

As you may have previously seen, SharePoint links are often a nest of GUIDs. This allows a neat little link to be produced instead: great for optimising scary archaic communication methods such as paper documents or VoYP (Voice over Yoghurt Pot).

I’ve used tinyurl simply because you can send the link to be shortened in a querystring, and nothing else is needed. Much as I love fetching API tokens and/or posting plain text login details, I used the most straightforward method for brevity’s sake.

<script type="text/javascript">
function getShortenUrl(ID)
{
var shortenUrl = 'http://tinyurl.com/create.php?url=';
shortenUrl += encodeURIComponent(document.getElementById(ID).firstChild.getAttribute('href'));
return shortenUrl;
}

function Custom_AddListMenuItems(m, ctx)
{
CAMOpt(m,’Shorten’,’window.open(getShortenUrl(‘ + currentItemID+ ‘));’,’/_layouts/images/LINK.GIF’);
return false;
}
</script>

There is very little difference between the two implementations, except as mentioned in the previous section.

<UrlAction Url="javascript:window.open('http://tinyurl.com/create.php?url='+encodeURIComponent(document.getElementById({ItemId}).firstChild.getAttribute('href')));"/>

Copy to clipboard (IE only)menuclipboard

A slightly more obvious method of copying an item’s direct link to the clipboard than the right-click menu. Handy for quick intuitive copying, or for broken mice.

Unfortunately this functionality is restricted to Internet Explorer (which covers most SharePoint users). Alternative solutions and their problems are covered pretty comprehensively on this Stack Overflow question.

<script type="text/javascript">
function setClipboard(ID)
{
window.clipboardData.setData('text',document.getElementById(ID).firstChild.getAttribute('href'));
}

function Custom_AddListMenuItems(m, ctx)
{
if (window.clipboardData)
{
CAMOpt(m,’Copy to clipboard’,’setClipboard(‘ + currentItemID+ ‘);’,’/_layouts/images/CLP16.GIF’);
}
}
</script>

The above sample takes advantage of the Javascript method’s flexibility, and does not display the option if the window.clipboard object is not present (i.e. not IE). But due to the restrictive nature of the Custom Action, we don’t have that ability.

<UrlAction Url="javascript:if(window.clipboardData){window.clipboardData.setData('text',document.getElementById({ItemId}).firstChild.getAttribute('href'))}"/>

Conclusion

The two methods of adding to the List Item menu each have their own benefits and restrictions.

The CustomAction method allows site-wide distribution and can be bundled with other CustomAction modifications (such as changes to the command ribbon), but it lacks flexibility and has very little granularity in its release (an entire list type). It also requires Visual Studio, and access to install such features.

Using Javascript in a CEWP is very flexible and much more readable for anything more than a very straightforward action. It can be added by power users rather than developers, without even using SharePoint Designer. Unfortunately it has to be added on every target view individually. If the Javascript was added to the master page it would result in an even less targeted release than the CustomAction option.

Both of these methods have very little item data to hand, but both can be greatly extended by making use of AJAX calls to SharePoint Web Services, 3rd party services, or custom pages.

Microsoft Office 365 – possibly the worst website design in the world – ever!

Date:November 17th, 2010 Author: Tags: , , ,
Category: General Comments:4 ;

So, as many of you know I work in marketing.  Since we are largely a web-based business I spend a lot of my time looking at and tinkering with websites.

And when I see really bad website design, it offends me.

I’m not so much talking aesthetics here.  Color schemes, layouts, text styles are after all pretty much a matter of personal taste.  Something that I view as hideous may be quite appealing to other people.

Read the rest of this entry »

SharePoint in the Cloud – Pie in the Sky?

Date:November 16th, 2010 Author: Tags: ,
Category: General, SharePoint Ideas Comments:2 ;

Yes, we’re wading into the SharePoint in the cloud debate! With major changes to SharePoint Online on the horizon, now may be a good time for us to re-examine the possible benefits that cloud computing could bring to you and your business.

pigs might flyI can’t describe cloud computing as the latest revolutionary breakthrough in software services; in fact, it seems as if the phrase has been around for a long time. But how many of you actually use the cloud to deliver your SharePoint software?

Read the rest of this entry »

SharePoint governance #2: The final frontier

Date:November 5th, 2010 Author: Tags:
Category: General, SharePoint Ideas Comments:4 ;

uss_enterpriseI started looking at SharePoint governance a few weeks ago and wow, is there a whole heap of information out there about it! And with the advent of SharePoint 2010, it’s clear that tightening up your policies is vital. The new social media enhancements mean that you’ll have to set some hard and fast rules about how your employees are going to handle this software at work – and make sure they behave themselves while using it!

I mentioned three points to guide your SharePoint governance plan in my last blog – roles, rules and routes – and in this one I’ll explore them further and give you more tips on what to start looking at when forming your plan.

Ultimately, there is no such thing as ‘one size fits all’ when it comes to creating your policy. In fact, you’ll probably find that the Microsoft guides on this are too laborious for you. The only thing you can do to create your own plan is dive in and get super involved with the whole process, from forming a good SharePoint team to gauging user feedback and making revisions to the policy. Brace yourself; we’re going through the final frontier…

Read the rest of this entry »

Editing The SharePoint List Item Menu (Part 2: Using Javascript)

Date:November 4th, 2010 Author: Tags: , ,
Category: SharePoint Development, SharePoint Ideas, SharePoint webparts, Training Comments:6 ;

MenuBeforeFollowing on from Part 1 of this series which covered Editing the SharePoint List Item Menu Using Elements, I thought it would valuable to reproduce the same results without using Visual Studio or SharePoint designer (Part 4 will be to do it without a monitor). This method will allow non-developers with view edit access to customise the List Item Menu.

In this example, a ‘View (new window)’ option will once MenuAfteragain be added to each item’s context menu to avoid the modal box, as illustrated to the right. Although as Christophe helpfully pointed out in response to Part 1, the modal boxes can be banished under the list’s Advanced settings. Fortunately there are many other uses for these techniques, as we will see in Part 3.

This example uses a Content Editor web part, which means the Javascript can be added on a view-by-view basis. This allows a more targeted release and can be added by any user with permissions to edit the view. However, it makes widespread distribution more difficult; putting the function in a master page can overcome this but will implement it for every item menu on every list.

Read the rest of this entry »

Editing The SharePoint List Item Menu (Part 1: Using Elements)

Date:November 4th, 2010 Author: Tags: , , , ,
Category: SharePoint Development, SharePoint Ideas, Training Comments:2 ;

The lovable modal boxWhile copying my rapidly lengthening scribbled to do list into a SharePoint Tasks list, my unconscious habit of middle-clicking items to come back to was being constantly foiled. Instead of opening a new tab the modal box kept popping up in the middle of my screen (new to 2010 I hear).

The drop-down menu options did exactly the same, leaving no alternative but to right-click the item, copy the link, manually open a new tab, paste it in, and switch back; much too much like hard work. So I decided to add an option to open the item in a new window… in retrospect probably harder work than just putting up with it.

The default item menu
The modified item menu

As a result, this is a brief run-through of how to add options to the context menu of list items in SharePoint, using a CustomAction in Visual Studio. For using JavaScript to the same ends, see Part 2: Using JavaScript (coming soon).

Read the rest of this entry »

Meet the New Boy–or how to Hire a SharePoint Developer

Date:November 3rd, 2010 Author: Tags:
Category: General Comments:5 ;

Stuart Pegg - smallAfter a long and rather painful summer of searching for a new developer to join our team, this week we are delighted to welcome Stuart Pegg on board.

First let me tell you a bit about the pain.  We knew it wasn’t going to be easy. We wanted someone who was going to be happy to immerse themselves in deep coding.  We made no secret of this.

We knew that tucked away as we are in a a little backwater of rural England we weren’t likely to get an experienced SharePoint developer.  If we could find a really hot ASP.NET/C# developer we were happy to train them up on the SharePoint bit.

But what we found in very long search was that although we did meet a few very good people, an awful lot of the people out there looking for jobs as developers didn’t seem to be able to  – well – didn’t seem to be able to develop really!

It was a bit of a shocker.  We followed the Joel Spolsky approach and set some practical tests at interview – things that we thought were pretty simple, and would be fair on candidates even under interview pressure.

But a surprising amount of people who looked great on paper and talked a really good talk at interview were totally flummoxed by our practical tests – a couple were even downright offended!

So – the learning form this for us is that just because a persons cv/resume is littered with every programming acronym know to man, and just because they tell you at interview that they are a Six Sigma Black Belt Agile Scrum Master, doesn’t mean they can actually write decent code.  Make them write some code at interview. And if they think that’s beneath them, then you probably don’t want them working for you anyway.

Stuart impressed us at interview by being the only candidate to explain his solution to our interview “test” programming problem so clearly that even a technophobe like me could understand it.

Having started on Monday, Stuart has continued to impress us by finishing all the work we had planned for his first week in just 2 days – that means he gets to make all the tea for the rest of the week!

Stuart joins us after spending 4 years working as a developer and manager at Club Communications, providing hosted ordering and billing platforms for the telecoms industry.

When he’s not working he enjoys hill walking and camping, reading and playing computer games,  and weekend visits to family and friends, where he inevitably gets roped into a bit of unpaid computer maintenance.

As he’s new to SharePoint Stuart is still in the honeymoon period of that love/hate relationship we all have with it.  He will be sharing his first impression in these pages over the coming weeks.

So welcome on board Stuart – mine’s tea with 2 sugars please!

Meet the New Boy–or how to Hire a SharePoint Developer

Date:November 3rd, 2010 Author: Tags:
Category: General Comments:5 ;

Stuart Pegg - smallAfter a long and rather painful summer of searching for a new developer to join our team, this week we are delighted to welcome Stuart Pegg on board.

First let me tell you a bit about the pain.  We knew it wasn’t going to be easy. We wanted someone who was going to be happy to immerse themselves in deep coding.  We made no secret of this.

We knew that tucked away as we are in a a little backwater of rural England we weren’t likely to get an experienced SharePoint developer.  If we could find a really hot ASP.NET/C# developer we were happy to train them up on the SharePoint bit.

But what we found in very long search was that although we did meet a few very good people, an awful lot of the people out there looking for jobs as developers didn’t seem to be able to  – well – didn’t seem to be able to develop really!

It was a bit of a shocker.  We followed the Joel Spolsky approach and set some practical tests at interview – things that we thought were pretty simple, and would be fair on candidates even under interview pressure.

But a surprising amount of people who looked great on paper and talked a really good talk at interview were totally flummoxed by our practical tests – a couple were even downright offended!

So – the learning form this for us is that just because a persons cv/resume is littered with every programming acronym know to man, and just because they tell you at interview that they are a Six Sigma Black Belt Agile Scrum Master, doesn’t mean they can actually write decent code.  Make them write some code at interview. And if they think that’s beneath them, then you probably don’t want them working for you anyway.

Stuart impressed us at interview by being the only candidate to explain his solution to our interview “test” programming problem so clearly that even a technophobe like me could understand it.

Having started on Monday, Stuart has continued to impress us by finishing all the work we had planned for his first week in just 2 days – that means he gets to make all the tea for the rest of the week!

Stuart joins us after spending 4 years working as a developer and manager at Club Communications, providing hosted ordering and billing platforms for the telecoms industry.

When he’s not working he enjoys hill walking and camping, reading and playing computer games,  and weekend visits to family and friends, where he inevitably gets roped into a bit of unpaid computer maintenance.

As he’s new to SharePoint Stuart is still in the honeymoon period of that love/hate relationship we all have with it.  He will be sharing his first impression in these pages over the coming weeks.

So welcome on board Stuart – mine’s tea with 2 sugars please!

New SharePoint FilterPoint web part – public beta released

Date:November 1st, 2010 Author: Tags: , , ,
Category: Filter, General, SharePoint webparts Comments:0 ;

FilterPoint SharePoint webpartWell finally, after months of hard work we are delighted to be able to let you know that we have just released our new FilterPoint web part for SharePoint in beta.

FilterPoint has been a long time coming so we hope you are going to like it.  It’s a tool that we always knew we wanted to develop. Dynamic filtering  – the ability to flip between filter values at the click of a mouse – is one of the building blocks for the kinds of rich applications that our customers like to build for themselves.  It builds on the power of webpart connections (a much neglected area in SharePoint) and once you have the ability to apply a group of filters to a page with a selection of webparts and lists you have the potential for some really nice dashboards.

But, as I said FilterPoint has been a long time coming, because what started out looking like a straight forward project turned out to be anything but . . . .

It starts off looking ever so simple with plenty of online examples – but when you start delving into the details it quickly becomes the stereotypical “Can of Worms” project.

There are basically two interfaces you can use – one old IFilterProvider interface , and the new ITransformableFilterValues interface. So far sounds easy but how about some wildcards….

With the new ITransformableFilterValues interface – you can’t create filters dynamically,  and you can’t have multiple connections on the consumer side in SP 2007.

On the other hand, with the old IFilterProvider interface you can’t send multiple filter values to List view web parts and you can’t connect more than one provider web part to a consumer web part. And that’s just scratching the surface.

To top it all off you have little control over what the filter consumer web part actually does with the info you give it – want to say “Equals” or “Not Equals” or “Greater Than” etc and thats out of the scope of what a filter provider can do (we’ve got some ideas on how to work around this in a future version of FilterPoint though).

My oh my, enough to make your head spin!

FilterPoint Webpart, filtering optionsAnyway- we’ve worked really hard to make this web part as simple to use as possible whilst still being compatible with any web parts that can accept the standard web part connections.  We have managed to come up with a tool which allows you to apply multiple filters to multiple webparts and lists, and (at least when working with our Planner and PivotPoint) you can have some control over the operator – using “not equal”, “greater than” and “less than” as well as the standard “equals”.  We hope to extend this aspect of the functionality in v2.

So, why might you want to use this thing then?

Well, you might want to use simply it to guide your users to the most relevant data in one list or webpart – giving them the ability to “filter on the fly”, selecting new data sets, and then clearing filters in one click.

Or, at the other extreme, you might want to bring together a collection of lists and web parts on one page, and use FilterPoint to create a truly dynamic dashboard for your users.

In fact, once you start to use filters and webpart connections there are any number of different ways to enhance the functionality of your SharePoint site with a tool like FilterPoint – we already have it set up on our Sales Pipeline and Client lists here, and are finding more possible uses every day.

We are planning to have FilterPoint ready for full public release by the end of the month.  In the meantime, if you pre-register for your free trial, you will qualify for a 25% discount on the product purchase price.

We hope you like it, and as always, we are keen to hear your thoughts and feedback.

Filterpoint Download

Sharepoint Governance #1 – aim for the sky

Date:October 18th, 2010 Author: Tags: ,
Category: General, SharePoint Ideas Comments:2 ;

So you’ve got your hands on SharePoint and you’re excited. Some might say we’re biased over here at the Pentalogic blog, but we definitely wouldn’t blame you for itching to deploy this user friendly and incredibly powerful server side software across your whole organization super quickly.

But wait a moment! Have you set out who will be in charge of migrating your shared drives to SharePoint, authorising new sites to be created and setting out an information lifecycle to manage your data? What about indexing information so it can be easily searched should you need an answer to be at your fingertips? If any or all of this sounds like a minefield to you, let me assure you that you’re definitely not alone.

Regulating SharePoint affects many users and most of us will look for guidance about managing our use of it at some point. With this in mind, we’ve put together a quick guide to explain why it’s vital to set out protocol for using SharePoint in your organisation sooner rather than later and have added some useful resources for you at the end.

Read the rest of this entry »