Blog of an overweight SharePoint addict

Sun 1 Aug 10

Task alerts not firing in new site from Content Migration.

Filed under: SQL, SQL2K8, SharePoint, Task Alerts, Troubleshooting — Reginald @ 8:49 pm

Whilst working with a client recently we decided to use the Content Migration system within SharePoint to allow us to create a template site that could then be used as the source for the 88 sites that needed to be created for each of the areas of interest.

Each site had identical set-up with regards to security and the groups involved, the data merely changed by geographical location, with each site representing a postal district. As the custom webparts all triggered from data such as the site title for their geo-location data, this provided us with the best mechanism for creating the structure.

During the UAT period however we did experience one problem that I didn’t expect, This related to task creation and the automatic notifications sent to users. In our template site, we created a standard out of the box task list and turned on the ‘Notify on Task Assignment’ option.

image

This worked as expected in test, but during the migration something happened to the alerts and none of the 88 sites sent alerts when tasks were created.

The first thing I do when task alerts aren’t working is to set-up an ‘Alert me’ on a list or document library. When this is done you immediately receive notification that this has been done, so this shows that the SMTP is configured correctly. Then creating a new item triggers the second alert (Be aware of the timer delay though, alerts may take up to 5 minutes to be triggered as this runs on a default 5 minute timer. (Which can be changed..))

In this instance, these tests worked ok. So, now knowing that the infrastructure was ok, I started thinking about how SharePoint handles this kind of alert. In alert parlance, these Task alerts are called immediate scheduled alerts, as opposed to the daily round up or journal alerts. When an alert such as this is created, an entry is made in the dbo.ImmedSubscriptions table.

WARNING: Doing any kind of querying into the SQL databases of SharePoint is NOT supported and this was done for investigative purposes only. I would recommend only doing this when all else fails OR, Microsoft tell you to do it!

image

In my test system, I created a new site collection and then a new tasks list. Initially for this site, task alerts were off so the ImmedSubscriptions table was empty. However after editing the properties of the tasks list and turning on E-mail notifications, the following data appeared in the content-db.

image

The key areas of information that we’re interested in are shown above, Primarily the Site and Web urls, the list name and most importantly the AlertTemplateName (SPAlertTemplateType.AssignedToNotification) and the filter that applies the alert.

In the case of the sites for my client, this data did not appear for any of the sites created from the Content Migration Package and we can therefore assume that when creating these sites, alerts do NOT get processed in the normal way.

The fix is simple, turn off the alerts and turn them on again, this creates the entry and alerts start working as expected. moving forward, we’ve now created a quick powershell script than turns Alerts off and back on again after the site is created using the SPList object and the EnableAssignToEmail property.

Paul.

Tue 24 Nov 09

Should I change the name?

To once a month updates?

I haven’t stopped since I got back from SPC and have been dashing around between clients working on SharePoint 2007 issues. Doesn’t anyone understand I want to play with SharePoint 2010 now? Or more to the point, I need to upskill in some areas very quickly to get the most of SP2010 and all the goodness it brings.

Looking at whats coming in SP2010, I honestly think the IT Pro’s have got it easy.. You guys just have to learn one new application, Us Devs have to learn at least 2, SP2010 and Visual Studio 2010!

Then on top of that, we have an updated object model to contend with, along with a brand new object model in the form of the SharePoint Client OM!

Add to this the requirements to use XSLT for almost every list view in SP2010, SPLinq (Call it SPlinq, MS hate that!!), Silverlight and a lot more Javascript than before, all adds up to a lot of skill-up time!

So here’s to spending many evenings and train journeys in front of Visual Studio, playing with Silverlight 101 and all the new Sharepoint tools that now come out of the box with VS!

I’m booked up in December as solidly as November was, so i wouldn’t expect too many posts on here just yet, although I am planning to extend the piece I wrote on KPI’s to give more ideas and hopefully present on this at a SUG do in the early new year.

Regards

Paul.

Tue 27 Oct 09

And, that’s a rap!

Filed under: General, Programming, SPC09, SharePoint, SharePoint 2010 — Reginald @ 7:02 pm

Well the MS SharePoint 2009 conference is over and life is slowly returning to normal. A couple of days away from SharePoint to restore my equilibrium and I’m now back to SharePoint 2007 and the real world.

But what of SharePoint 2010? When can we see it in all it’s glory. Well Steve Ballmer announced that the Beta 2 release would be sometime in November as they were doing last minute testing internally in Microsoft. During the conference, all of the SharePoint web pages were switched over to the new version and reports coming out suggest no major problems. So fingers crossed for an early Beta 2 in November.

The conference for me was all about soaking up the changes to development in SP2010. I didn’t really focus on any of the admin sessions at all as I’m planning to download and watch them on my long journeys to work over the next few weeks. So what does SP2010 bring to us Devs?

Well the big story is the much improved integration with Visual Studio 2010. (Beta 2 available now) which ships with an absolute ton of SharePoint 2010 project templates from Web Parts to Event Receivers, List Definitions, Content Types etc.

And the biggest win for me.. ONE TOUCH DEPLOYMENT!! Yes.. hit F5 and your project deploys to your test server with nary a hiccup and just a minor bit of configuration during the project set-up. Gone are the days of configuring your DDF files and your WSPs (Well once we convince all of our clients to switch to 2010 that is!!)

So my top 5 improvements (i reserve the right to get more excited about others as time unfolds):-

  1. One touch deployment for testing
  2. Automatic creation of the WSP (This should encourage more solution deployments)
  3. Visual Webpart designers (Think using a User Control without needing Son of Smart Part)
  4. Content Types that can be deployed and updated
  5. Vastly improved Tableless design

Over the next few weeks I’ll be playing with Beta 1 with Visual Studio 2010 Beta 2 (If they play nicely together) and hopefully will be rearranging this list and probably expanding it. Beta 1 is still under NDA, so nothing that hasn’t been mentioned at SPC09 will be raised, but hopefully Beta 2 won’t be far around the corner.

Paul.

Tue 13 Oct 09

Tentative Schedule for SharePoint Conference 2009 – Las Vegas

Filed under: General, SPC09, SUGUK, SharePoint, SharePoint 2010 — Reginald @ 2:53 pm
Join me at SPC09

Twitter @Cimares

Ok, so Microsoft finally released the full session schedule during the last 24 hours and I’ve tentatively booked the sessions that I want to go see.. And this has to be subject to change because there are so many great sessions that i want to get into. Thank god Microsoft are going to provide an AV feed of all sessions within 48 hours of them finishing. Hopefully I can download these and watch them on the train into work during the following week.

So, here’s my current schedule..(Subject to Change.. Hastags for Twitter Search)

Saturday 17th

  • Arriving about 2:30pm PST
  • Gambling and trying to avoid jetlag! Probably joining @jthake somwhere in Vegas

Sunday 18th

  • Getting to see Vegas,
  • Catch the Formula 1 somewhere (#ShareF1)
  • 18:00 ish.. register then #SharePint

Monday 19th

  • 9:00AM – Keynote Speech – Steve Ballmer
  • 10:30AM – Keynote 2 – Jeff Teper
  • 1:15PM – Overview of the SP2010 Developer platform
  • 2:45PM – Visual Studio 2010 SP Development Tools Overview
  • 4:30PM – Developing with SP2010 Sandboxed Solutions
  • Evening – no idea yet..going with the flow.

Tuesday 20th

  • 9:00AM – Advanced Webpart development in VS2010
  • 10:30AM SP2010 based document assembley and manipulation using Word
  • 1:15PM – Authentication & Authorisation in SP2010
  • 1:15PM – Deep Dive Open XML and Open XML SDK
  • 2:45PM – SP2010 Upgrade part 1 – Fundamentals
  • 4:30PM – SP2010 Development Best practices
  • Evening – 80’s Beach party!!!!! and then #TweetupSPC09 if it’s still going on

Wednesday 21st

  • 9:00AM – Workflow development in SP2010 with VS2010
  • 10:30AM – Developing with the new User Interface features in SP2010
  • 1:15PM – Developing with REST and LINQ in SP2010
  • 2:45PM – Extending the VS2010 SP tools with new Designers
  • 4:30PM – Customizing the VS2010 Sharepoint deployment process
  • Evening – Jury’s out on this one.. might go watch #ShareHoldem

Thursday 22nd

  • 9:00AM – Load testing SP2010 with VSTS
  • 10:30AM – Deep Dive into SP2010 Profile Store and profile Data
  • 1:15PM – Application Lifecycle Management for Developers in SP2010
  • 2:45PM – Building rich dynamic websites with SP2010
  • Evening – #ShareHofBrau – Last chance to catchup with SP stragglers..

Friday 23rd

  • 16:40 Takeoff for London Gatwick!! (arrives 10:30AM!)

So all told a pretty rammed week.. But I’m REALLY looking forward to it..

Tue 6 Oct 09

Whats the record for the longest Calculated SharePoint column?

Filed under: Calculated Fields, General, SharePoint — Reginald @ 3:28 pm

Well my longest to date is 304 characters.. I’m not quite sure what the SharePoint limit is, but here’s mine…

=IF(LEN(MONTH(Dated)/3)=1,TEXT(Dated,”mmm-yy”),IF(LEN((MONTH(DATE(YEAR(Dated),MONTH(Dated)+1,DAY(Dated))))/3)=1,TEXT(DATE(YEAR(Dated),MONTH(Dated)+1,DAY(Dated)),”mmm-yy”),IF(LEN((MONTH(DATE(YEAR(Dated),MONTH(Dated)+2,DAY(Dated))))/3)=1,TEXT(DATE(YEAR(Dated),MONTH(Dated)+2,DAY(Dated)),”mmm-yy”),”ERR”)))

“And what pray, does that monstrosity do”, I hear you ask…

The answer is, it simply works out which quarter of the companies financial year the item appears in. The list item has a column called Dated which is a date only field.

Our financial year runs 1st Oct to 30th Sept with each quarter ending Dec,Mar,Jun,Sep.

In order to work out which quarter the item is in, I’ve nested 3 IF’s together.. If you’re not familiar with how the =IF function works in a calculated column, then it breaks down like this..

=IF(jonnysapples > janesapples,”Jonny has more apples”,”Jane has more apples”)
=IF(SOMETHING TO TEST) , DO THIS FOR TRUE , DO THIS FOR FALSE)

So in this instance if the column named Jonnysapples does indeed have more apples in it, then the phrase “Jonny has more apples” will be displayed in the resulting column. If it doesn’t, then “Jane has more apples” will be displayed.

Excellent.. So now what we want to do, is replace the output statement for FALSE (”Jane has more apples“) with the next test to see if Jonny is unhappy.

e.g.

=IF(jonnysapples > janesapples,”Jonny has more apples”,IF(jonnysmoney>0,”Jonny doesn’t care as he can buy some more”,”Jonny is upset because Jane has more apples”))

So, working the logic through,if Jonny has more Apples, we’ll see “Jonny has more apples“, if he has less, but some money (After checking the money column), then we’ll see “Jonny doesn’t care as he can buy some more” and then finally, if Jonny has less apples and no money, We’ll see the final state of “Jonny is upset because Jane has more apples

So now we’ve implemented a 3 state result. By nesting a further if statement we’re able to twist this solution to our means.

So now we need to look at what logic we’re actually implementing in each of the IF statements.If you extract the “Something to test” part out of the first statement you’ll see:-

LEN(MONTH(Dated)/3)=1

Now if you bear in mind that the months that represent our year quarter period ends are all a factor of 3, then it starts to make sense. (Sept – 9th Month, June, 6th Month etc) Take the numeric value for the month. if you divide it by 3 and get a whole number e.g. a result with a length of 1, then we’re in a month divisible by 3. if we get any form of decimal, then we’re not.

=IF(LEN(MONTH(Dated)/3)=1,TEXT(Dated,”mmm-yy”),”DO THIS FOR FALSE”)

So if the month can be divided by 3 without any decimals, we’ll output the Dated column, formatted to look like mmm-yy. If it can’t then we’ll step into the next if statement in place of “DO THIS FOR FALSE”.

Again, very similar logic, however this time, we’re going to add 1 month to the date in Created and test that..

IF(LEN((MONTH(DATE(YEAR(Dated),MONTH(Dated)+1,DAY(Dated))))/3)=1,

If that results in a whole number, then we’ll output the Created+1 month using TEXT(DATE(YEAR(Dated),MONTH(Dated)+1,DAY(Dated)),”mmm-yy”),

And if it doesn’t? Yep you guessed it, we step into the third and final IF statement which we know is going to be true because the 4 month will divide by 3 once again. However to keep the parser happy, we’ve got to have an option of something to output for False, so that’s where you’ll see “ERR” in the formulae.

If this has worked, all you’ll see in your calculated column is Sep-09,Dec-09,Mar-10,Jun-10 etc….

This solution might not work for your if you use a different financial year and quarters, but the principal is sound..

Regards

Paul.

Thu 1 Oct 09

Creating a Sales Dashboard using the DataViewWebpart & XSL

Filed under: SharePoint, Training, XML — Reginald @ 7:51 pm

So not too long ago, a client of mine decided that they wanted some nice charts on their WSS based intranet. You see the problem straight away.. No Moss, so no access to the KPI webparts, so it was time to drop to the old faithful, the Data View Web part to solve this problem…


Scenario:- The Sales Director wants to have a screen in SharePoint where he can monitor all Sales Managers performance against target for the current month.

Use case:-
• Data should be displayed as a single bar for each sales manager.
• Data should also be broken down against the targets for Consultancy and Managed services.
• Sales Data will be entered as Sales order numbers are generated on receipt of a firm order.
• Sales target will be 1/12 of the yearly target. No adjustment will be made for time of year.
• Bar colour should change depending on % of target achieved. <50,50-99,100 will be the bands used.

First we create a custom list called Sales that will be used to track every sale, this is created with the following fields.

Title ———– String – Sale comment
Value ———– Currency – Value of the sale
Account Manager – Lookup – A lookup to the list of Sales Managers
Sales Type —— Lookup – A lookup to the list of Sales Types
Client ———- BDC Lookup to SalesForce (Use a string for now as it makes no difference to this example)
Date of Sale —- DateTime (Date only)
StartofMonth —- Calculated (DateTime-Date only) – This field is calculated using the following formulae to give the first day of the month this order was dated in. (See below for an explanation of why we use a calculated column)

=DATE(YEAR([Date of Sale]),MONTH([Date of Sale]),1)

EndofMonth —— Calculated (DateTime-Date only)– This field is calculated using the following formulae to give the first day of the month this order was dated in. (See below for an explanation of why we use a calculated column)

=DATE(YEAR([Date of Sale]),MONTH([Date of Sale])+1,1)-1

Be careful with the creation of the column Date Of Sale as this will be used in a CAML query later on. I didn’t create this column and therefore the spaces get encoded in the CAML string (Date_x0020_of_x0020_Sale).

Best practice when creating columns is to create them with a concatenated name first, then edit and expand the name later. E.g. DateOfSale is created, then renamed Date Of Sale. The internal name remains DateOfSale, rather than Date_x0020_of_x0020_Sale!

The following data has been populated for testing (Note: I’m using this test in September, so adjust the date of sale to match the calendar month that you’re testing in.)

The test data for our chart.

The test data for our chart.

Once you’ve got that small amount of data, we’ll also need to upload the three colour images used by the CSS in the creation of the colour coded bars for the chart.

These small files can be taken from here using right click and save as. (Don’t worry about the size as they are actually only 1 pixel wide.)

RedBarYellowBarGreenBar

Red Yellow and Green bars for the chart.

Once you’ve downloaded these images, save them into the /12/TEMPLATES/IMAGES/ directory on your server (All WFE’s if installing this in a farm.)

The next step is to fire up SharePoint Designer and open up your website (Sandbox environment please if this is the first time!). In order to keep the look and feel nice and similar, I decided to copy the default.aspx in the root of the site, and repasted it as monthlyreports.aspx (all in SPD). Open this page in the browser and delete (not close) any webparts that are on the page. This should leave us with a nice clean page with the left nav and top chrome all visible.

Back to SPD and it’s time to add the DataViewWebPart. Click on the ‘left’ webpart zone in the design canvas to select it, then click on Insert/SharePoint Controls/DataView to place a new data view on the page.

SPD should look something like this now:-

DataViewWebPart

DataViewWebPart

Now we have the DVWP inserted, you should now see the Data Source pane on the right hand side. Look in the library for the list we created earlier. Right click on it and choose show data. this will display the list of available fields. For our Query we’re going to need the first five columns, Title, Value, Date of Sale, Account Manager and Sales Type.

Fields

Fields

Once these are highlighted, click ‘Insert selected fields as – Multiple Item View.’

Once done, you should see our test data displayed in tabular form in the design view. The only problem here is that it’s all of our data, unfiltered and unsorted. At this point, you could use a filter in the data view itself, but what I want to achieve is to restrict the amount of data actually being returned by the data query in the background. To this end, we’re going to change the select command used by the DVWP to only return data for the current month.

Switch to the code view in SPD and find the top of the DVWP declaration in code. It should look something like this:-

We’re going to replace this with our own bit of CAML query language to return just the data that we want.

(Note: When I originally designed this solution, I came up with the calculated columns idea that results in the query below. When I delved further into CAML date filtering, it was suggested that I look at using a construction instead but I found that items for the last day of previous months were sometimes creeping in.)

So, using the StartofMonth and EndofMonth columns, we have a query that looks like this:-

<Query>
   <Where>
      <And>
         <Leq>
            <FieldRef Name='StartofMonth' />
            <Value Type='DateTime'><Today/></Value>
         </Leq>
         <Geq>
            <FieldRef Name='EndofMonth' />
            <Value Type='DateTime'><Today/></Value>
         </Geq>
      </And>
   </Where>
</Query>

And returns only those entries that exist within the month we’re currently in (That’s using the entry. You could specify a date if you wanted results for that particular month.)

So, paste that query into the select command, save the file (don’t worry about the ghosting message, we’ll sort that out later if performance is a concern for you.), and you should now see a view similar to the following. (notice that I haven’t bothered encoding the <> as SPD will do that for you when the file is saved.

Query in Code & Results in Design View

Query in Code & Results in Design View

So if we now browse to our web/monthlyperformance.aspx page, you should see a nice data form with 4 items for the current month visible. If you can see any items that shouldn’t be there, then you may need to test your query is working using U2U’s CAML builder.

At this point we now have the data that we want to represent in Bar chart format, but represented in list form. This is the point where it starts looking like code as we delve into the wonders of XSL to transform the raw list data into a nicely styled view for our director.

To make this easier to manage, we’ll use an external XSL file to transform the data and point the DVWP at it. Here’s the XSLT that we’re going to use. Cut and paste it into notepad, save it as something useful like ‘SalesGraphsByAccountManagerForMonth.xsl” and then drag and drop it into the root of your site in SPD.

The xsl file is commented heavily so should explain whats happening to enough of a degree that you can change this to sort your own ends.

SalesGraphsByAccountManagerForMonth

Once the xsl file has been edited to meet your needs (More importantly to match the Account Manager names etc in your data), the DVWP can be pointed at it.

Open the MonthlyPerformance.aspx page in your browser and select edit page. Select modify shared webpart on the drop down option on the DVWP and then click on Miscellaneous.

Click on XSL link and enter the URL of the XSL file that you dropped into the root of your web.

Click on OK and your page should magically transform into the view below.. (Note: I over achieved against my targets as you can see, having achieved 915% of my target. The bar chart however stops at 100%! This is quite deliberate!)

Results if all went well

Results if all went well

Troubleshooting

If you see the bars but no values, then your field names are most likely the culprits. Make double sure that you are using the internal name as SharePoint knows your fields. To double check this, browse to the list settings for your chosen list, Click on the column name and check the URL in IE. You should see a querystring in the form &Field=Sales_x0020_Type or similar. This is your internal name.

Ghosted/Unghosted Pages

If you’re worried about having an unghosted page in your web, simply export the webpart that you’ve created. Delete the page and re-create it, then import the webpart once more.

Hopefully this little guide has helped you out.

Regards

Paul.

Mon 10 Aug 09

Eeek.. slacking again..

Filed under: General, Programming, SPC09, SharePoint, SharePoint 2010 — Reginald @ 3:48 pm

Yes it’s nearly a month since my last confession again… And a busy one at that…

Shortly after the first videos were sent out by Microsoft, my company got accepted into the early adopters program, and also the Technical Beta!!

So now, I have to squeeze in some time to start writing new articles on SharePoint 2010 in readiness for publication on the day the NDA is lifted.. which I predict will be around the start of the SharePoint conference in Las Vegas on Ocotober 19th which I’m very pleased to be able to say I’m attending!! I sorted out my registration this afternoon, with flights and hotels to be booked this evening..!!

But before all this happens, I have to finished these confounded event handlers on a list with Item approval.. watch this space.

Paul.

Mon 13 Jul 09

SharePoint 2010 – Sneak Peak!

Filed under: SharePoint, SharePoint 2010 — Reginald @ 2:06 pm

Today at the New Orleans Partner Conference, Microsoft announced the SharePoint 2010 sneak peak website.

I’m currently watching the sneak peak videos now and it looks like we’re finally going to get a little bit more information than the current vapourware rumours that currently exist.

http://sharepoint.microsoft.com/2010

Paul.

Sun 5 Jul 09

Pre-populating the BDC item picker in an application page

Filed under: BDC, Programming, SharePoint, Uncategorized — Reginald @ 5:21 pm

Adam Toth wrote a very good article on his old blog about using the BDC Entity Picker in an application page. Click here for the article.

What Adam didn’t cover however is what happens if you want to pre-load that picker with some information. In my instance, I was copying a list item with BDC data in it and wanted to allow the user to view and change the selected BDC field.

It turns out that it wasn’t as difficult as I was expecting, and after some research in the SDK about the BDC Item picker I was able to produce the effect I wanted.

I’m going to assume that you’ve followed Adam’s guide thus far and have been able to get the BDC Itempicker on your page and have it talking properly to the BDC (E.g. you can search for an item and have it populate the picker.) If you haven’t got this far, go and do that first as it’s fundamental to what we’re going to do.

So in my scenario, The list item has a BDC field for Client name. The first thing that you need to understand is how SharePoint stores the BDC Field data in the SharePoint list. I was expecting to have a new field type to play around with, but No, it’s much easier than that, you get two strings. One for the display value and one for the Entity key.

In my BDC application definition, I have an entity called dbo.Customers and this has already been added to the list definition as a Business Data column. If you write a quick console application to browse through the field names, you’ll find 2 fields, one called “Client” frm the field definition in the list and one called “dbo_x002e_Customer_ID” (This latter one was added when the field was configured.)

So with the values of these two fields we can create a PickerEntity which can be understood by the BDC Itempicker.

The PickerEntity was declared earlier in the code and then is used as follows:-

if (item["Client"] != null)
{
    if (item["dbo_x002e_Customer_ID"] != null)
    {
        peClient = new PickerEntity();
        peClient.DisplayText = item["Client"].ToString();
        peClient.Key = item["dbo_x002e_Customer_ID"].ToString();
        bdcClientSelector.Entities.Add(bdcClientSelector.ValidateEntity(peClient));
    }
}

Hopefully this will help demystify the Itempicker a little..

Paul.

Fri 26 Jun 09

Event handlers from code – redux!

Filed under: General, Programming, SharePoint — Reginald @ 8:20 am

Ok, well I think I’ve worked out why the GUId isn’t getting defined.

The code I’ve written creates an EventHandler on the base content type. When this content type gets assigned to a library, the content type is instanced to the library and as a result I think the GUID i assign is removed.

I think were I to assign an event handler directly to a list, then this wouldn’t be the case and I could give a GUID in the creation method.

I’ve not tested this yet, but it seems to make sense.

Paul.

Older Posts »

Powered by WordPress