Archive for the ‘Training’ Category

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.

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.

(more…)

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

(more…)

SharePoint Terminology – Farms, Web Front Ends, Web Application and Sites

Date:July 8th, 2010 Author: Tags: , ,
Category: General, SharePoint Development, SharePoint Ideas, Training Comments:9 ;

There is a great deal of confusion around some terms related to the different levels of SharePoint hierarchy. Some of this is buzword overload and some  has been brought about by inconsistent usage from Microsoft (and to be fair actually most of us in this industry).

So if you’ve ever wondered what things like Farm, WFE, NLB, Web Application, Site Collection and Top Level Site mean I am going to try and clarify the different terms without getting too technical as some of this stuff needs to be know by advanced, or power, users. I’ve missed out some of the more esoteric things like managed paths in the interests of readers sanity.

SharePoint 2010 Resources

Date:May 27th, 2010 Author: Tags:
Category: General, Training Comments:0 ;

Last week we had an email from a customer who was confused about his options for SharePoint 2010.

He was planning to move his 5 WSS site across to SharePoint 2010 Foundation – but had found this document from Microsoft:

SharePoint 2010Resources

http://sharepoint.microsoft.com/en-us/buy/Pages/Licensing-Details.aspx

which seems to suggest that sites and Workspaces were not available in Foundation, only in SharePoint 2010 standard edition or above.  Well we knew this wasn’t right;  but that wasn’t what the info from Microsoft seemed to be saying.

This gave us a reminder of just how confusing our friends at Microsoft can make things.  So we thought we would gather together some handy resources for all of you who may be thinking of moving over to SharePoint 2010. As always we have focussed mainly on users and administrators.  I hope you find it useful.

(more…)

SharePoint Site Templates: KISS guide to creating, saving and using

Date:April 27th, 2010 Author: Tags: ,
Category: General, SharePoint Ideas, Training Comments:2 ;

A site is the key place within SharePoint to bring together all the people, content and activities associated with a particular process, project or group.  And if the process or project is regularly repeated within your organization having a site template for it saves a lot of time and helps to ensure consistency and facilitate continuous improvement.

There are any number of scenarios where you might use a SharePoint site template, for this example we are using a recruitment process, but you could equally well set one up for any regularly repeated process or project you manage: training courses, audits, conferences and sales exhibitions, product testing, office moves, procurement, risk assessment, staff appraisals – the list goes on.

SharePoint comes with some Out of the Box Templates, there are other available on-line, free or to purchase.  But all of these are “off the peg” options: great if you are short on time, but they’re not going to be a perfect fit for your business processes.

To get a SharePoint template that fits your processes perfectly you are going to have to make your own – and thankfully it’s exceptionally easy to do – so here’s how.

(more…)

SharePoint Partner Perspective: Veronique Palmer

Date:April 1st, 2010 Author: Tags: , ,
Category: General, Partners, Training Comments:1 ;

This is the first in a series of interviews with our partners  – giving insights into what’s happening in their part of the world and in their part of the world of SharePoint.

And our first interviewee is Veronique Palmer.

We first met Veronique in discussions on the SharePoint Experts Group on LinkedIn, which she co-manages and moderates.  Veronique is based in Johannesburg, South Africa and is owner and founder of Lets Collaborate.

veronique

(more…)