Making Sense of the SharePoint World

Aug-252009

Advanced Calculations in SharePoint Designer Workflow

MCj02380230000[1]

In this two part series, I'll be showing you how to take advantage of SharePoint calculated columns in your SharePoint Designer workflows. Part 1 will introduce calculated columns. Part 2 will show you how to consolidate your columns into a "function library" of sorts.

Part 1 of 2: When Basic Arithmetic Won't Cut It

SharePoint Designer workflows are very powerful, but there are a number of acknowledged limitations. One of these is the fairly limited selection of operations for performing calculations. For numbers, you have a basic selection of arithmetic (add, subtract, multiply, divide, and mod) operations, but no advanced math. For strings, you have the dynamic string builder, but you have no way to break down, or analyze, a string.

One way around this would be to design custom actions to perform the desired manipulation. But that requires Visual Studio, coding skills, and installation on the server by a willing administrator. Fortunately there is another option, already built into SharePoint, that gives you access to a wide array of functions.

Meet the Calculated Column

This option is the "Calculated Column". While this isn't a direct part of a SharePoint Designer workflow, your workflows do have access to the calculated columns in he lists and libraries of your site. If you haven't used a calculated column, this is a feature in SharePoint that allows you to create a column (or field) based on information contained in other fields in your list.

Creating a calculated column is pretty easy. Just select "Create Column", either from the Settings dropdown of a list view, or from the Columns section of your list's settings page. Near the bottom of your Type choices will be "Calculated".

image

When you select Calculated, the Additional Column Settings section is changed to show the Formula builder. In the example shown below, I have two date fields, Start and End. I want to know how many days are between them. All I need to do is enter the formula [End]-[Start], and I now have the duration of my event.

image

Note: After you save a formula, it is reformatted slightly, so if you go back into the field to review it later, you will see "=End-Start". You can also enter the formula directly in this format if you like.

But in addition to being able to display this in my list, I can now use that duration in my workflow to make decisions. For example, if the list is a time-off notification form, I might want to alert HR to arrange temp coverage if the employee is going to be out for more than 3 days:

image

Of course, that was a very simple calculation, and one that could have been done within the workflow. Where the calculated column starts coming into its own is more complex operations.

Let's say our time-off notification list is configured to allow people to email their requests into it. That's simple enough - SharePoint supports email enabling in several list types.

But, what if you want to process the request differently based on information in the subject line, such as whether the person is on vacation or sick. Your convention might be to put extra information in the subject (e.g. "sick - going to the doctor"). The relevant information to the workflow is to the left of the dash, so you need to grab just that. You could create another calculated column, called "Reason". The formula here is a bit more complex:

TRIM(LEFT([Title],FIND("-",[Title])-1))

You can find a complete list of the functions available for calculated columns at either of these links (the list is the same for WSS and MOSS):

http://office.microsoft.com/en-us/sharepointtechnology/CH100650061033.aspx 

http://office.microsoft.com/en-us/sharepointserver/CH101760291033.aspx

There are a couple of limits to be aware of when creating calculated columns:

  • You can only nest functions 8-deep
  • Your total formula length can't exceed around 1000 characters.

A Good Start

In this post, I've shown you how SharePoint calculated columns can help you get around the limited calculation ability built into SharePoint Designer. You can use calculated columns to perform almost unlimited manipulation of your SharePoint data, and make use of that in your workflow. But what if you need many calculations in your workflow, or you don't want your users to see any "interim" values? In Part 2, I'll show you how to build a "function library" that you can call from any SharePoint Designer workflow in your site.

Until then, Happy Computing!


Aug-192009

My Free SharePoint Twitter Integration Components

MPj04389110000[1]

Yes - I Still Like Twitter!

If you've been following my saga over the last few weeks, you'll know that I was temporarily suspended from Twitter due to a cross-site attack, that caused an inappropriate spam link to be injected into my tweetstream. While I am still disappointed that it took Twitter customer service almost two weeks to reinstate me, I do still like Twitter.

In an effort to "bury the hatchet", I am re-posting links to some components I wrote to bring Twitter into SharePoint. The first two are simple and fancy Federated Location Definitions for Search Server 2008, or MOSS Search (post-Infrastructure Update). The third is a simple Data View web part that can provide a twitter search result on any SharePoint page, including WSS.

(Note: For all of the download links below, right-click and choose "Save target as" to retrieve them.)

Federated Locations

See the original articles: Part 1, Part 2

Download the "basic" Twitter search results Federated Location Definition Download the "deluxe" Twitter search results Federated Location Definition
image image

Data View Web Part

See the article on how to create this part.

Download this part.

image

You can see all three components in action here.


Aug-122009

Twitter Account Reinstated

I finally got the attention of someone in Twitter support. They have reinstated my account, but I still don’t have a solid confirmation of why I was suspended in the first place. My other posts list my suspicion, but if they ever give me a good explanation, I’ll pass it on to you, so hopefully you won’t fall into the same trap.

Until then, Happy Tweeting!


Published: Aug-12-09 | 0 Comments | 0 Links to this post
Tagged as:

Aug-112009

An Open Letter to Twitter Support

To Whom it May Concern:

I am becoming very frustrated over the amount of time it is taking for you to resolve my issue and reactivate/unsuspend my account.

As far as I can tell, I was suspended for inadvertently accessing a spam site, which used a cross-site scripting vulnerability to inject an untoward post into my stream. While I immediately addressed the problem and deleted the offending post, your system had already automatically suspended my account.

It has now been almost two weeks, and I still have not even had anything other than a single automated acknowledgement of my issue. Yet you have closed my issue twice as resolved, without any actual resolution having taken place. I have also posted a public apology to my followers on my blog, which based upon my treatment here, I am starting to regret (not regretting apologizing to my followers, but for believing that the suspension might have been in any way justified).

While this delay may simply be a sign of "growing pains", you will need to make significant improvements to your customer service if you wish to continue growing - especially if you hope to venture into paid-level services.

I would appreciate a direct response to my queries, an unsuspension of my account, and an apology for the delay at your earliest convenience.

Sincerely,

Woodrow Windischman
(@WoodyWindy)

Published: Aug-11-09 | 6 Comments | 0 Links to this post
Tagged as: General