zevenseas


 

This form was customized not working with attachment – Solved!

Remember the ‘This form was customized not working with attachment’ error when you tried adding an attachment to your custom editform/newform which was built using SharePoint Designer? Well, while reading Laura Rogers’'s blog, I came across her post indicating that Microsoft finally released a hotfix for this issue! ;)

Head over to http://support.microsoft.com/kb/960311 , download the hotfix and update your copy of SPD to create custom forms while maintaining the attachment functionality!

 

ps. Pretty funny to see that when googling on ‘This form was customized not working with attachment’, the first hit is the post on my old blog ;)

A dutch SharePint this upcoming friday..

What?

If you like beers (or any other beverage) and like SharePoint then you most likely like SharePint! Come and join us this friday evening in Amsterdam! Together with Joel, Mike, Waldek, Matthijs, Ton, the whole zevenseas team and many others, we’ll be drinking beers and gossiping about the SharePoint community and maybe (just maybe…) we’re even going to talk about SharePoint ;)

 

Where and when?

Starting around 19h..  @ De Veranda (http://www.deveranda.nl)
Amstelveenseweg 764
Amsterdam

See you there! :)

Application Pages and choosing the right master page

In the past few months I’ve gained some experience in building custom application pages. And I wanted to share some things I’ve come across while building those pages.
First of all when provisioning these pages, you have two choices of folders to put them in.

  1. ADMIN folder, use this folder when your application pages should be accessed only via the Central Admin.
  2. LAYOUTS folder, use this folder when developing application pages that can be accessed by every web or site.

Next to those two folder options you also have the choice of which masterpage to use. When creating Application Pages that end up in the

  • ADMIN folder (12hive/Templates/ADMIN) attach the following masterpage:
<%@ Page Language="C#" MasterPageFile="~/_admin/admin.master" Inherits="Custom_Solution.Custom_Class" %>
  • LAYOUTS folder (12hive/Templates/LAYOUTS) attach one of the following masterpages:

<%@ Page Language="C#" MasterPageFile="~/_layouts/application.master" Inherits="Custom_Solution.Custom_Class" %>
<%@ Page Language="C#" MasterPageFile="~/_layouts/layouts.master" Inherits="Custom_Solution.Custom_Class" %>
<%@ Page Language="C#" MasterPageFile="~/_layouts/simple.master" Inherits="Custom_Solution.Custom_Class" %>

Below is a finding of some weird behavior I came across when I accidently was referring to a masterpage that was in another folder than the page.

  • Page location: ADMIN folder
    Referenced masterpage: ~/layouts/simple.master
    • Symptom : Simple page with some TextBoxes that were loaded with data from a database and at the bottom a button to save changes. When I clicked the button I immediately got a “The security validation for this page is invalid” error.
    • Solution : Change the masterpage to ~/_admin/admin.master or to ~/_layouts/application.master

So I reckon it’s best to use the masterpages that you can find in the corresponding folder. Just to avoid the troubles you might  get ;)

LCM updated

A quick update from the LCM front.. I made the following tweaks:

  • Only WSS controls in the application pages so the solution works on WSS-only installations as well.
  • When a site get’s deleted and the checkbox “Log deletions in SharePoint” is checked, now the storing the data of the site is done by making use of webservices. I had some trouble in accessing the Central Admin without being farm admin (and why and how is another blogpost itself which will be out very shortly ;)

You can still get it here from CodePlex ;)

Extending CQWP by doing a bottom-up aggregation

You might wonder what bottom up aggregation means in this context.. well.. let me explain this by using the following example:

Let’s say you have a portal with the following structure

  • Main Portal
    • Departments
    • Products
      • Product A
        • Document Library
      • Product B
        • Document Library

and you want to aggregate all the information from the bottom (Product A) to the upper most level (Main Portal). But you don’t want any information from other products or even from Departments. Now by default the CQWP will aggregate everything under a given site/sitecollection.

So.. what to do? First we create our own version of the CQWP by inheriting from it like this:

public class BottomUpAggregationWebPart :
 Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart

To change the result of the CQWP we can manipulate the DataTable that is created by the CQWP by using a delegate like this:

protected override void OnInit(EventArgs e)
{
    this.ProcessDataDelegate += new ProcessData(modifyData);            
    base.OnInit(e);
}
private DataTable modifyData(DataTable dt)
{
    //do something 
    return dt;
}

For every row in the DataTable there is a column called “WebId’. This GUID is , as you might have guessed, the ID of the web where the item belongs to. So, all we need to do is filter out all the rows where the WebId is not part of the parent chain. To determine which web is part of the chain I’ve created the following recursive method:

private void DetermineDepth(SPWeb web, ref List<Guid> webIds)
{
    if (web != null)
    {
        if (web.Url != SPContext.Current.Site.RootWeb.Url)
        {
            webIds.Add(web.ID);
            DetermineDepth(web.ParentWeb, ref webIds);
        }
        else
        {
            webIds.Add(SPContext.Current.Site.RootWeb.ID);
        }
    }
}

Next is the filtering itself which looks this

private DataTable modifyData(DataTable dt)
{
    //Getting a List with all the SPWeb.ID's from the current SPWeb to the RootWeb of the SiteCollection
    List<Guid> webIds = null;
    webIds = new List<Guid>();
    DetermineDepth(SPContext.Current.Web, ref webIds);

    webIds.Sort();

    List<DataRow> rowsToDelete = new List<DataRow>();
    foreach (DataRow row in dt.Rows)
    {
        if (!webIds.Contains(new Guid(row["WebId"].ToString())))
        {
                rowsToDelete.Add(row);
        }
    }

    //Delete the rows
    foreach (DataRow row in rowsToDelete)
    {
        row.Delete();
    }

    return dt;
}

And that’s it! ;)

The only thing to keep in mind is that when you have set the item limit in the presentation settings, this item limit is set before you have the chance to modify the DataTable. So it’s best to to not have an item limit at all or a modified one. If you wish to modify the property in code, here’s the snippet which you can use:

this.ItemLimit = -1;

While I’m covering the subject of the CQWP,  I also want to share some experiences and assumptions that I had when dealing with it. (Please note that for the most time when I’m developing with SharePoint I really tend to stick to WSS ;)

One of the assumptions I had was that the CQWP aggregated based on a given content type OR list type/template in the properties of the webpart. However, as I found out, this is not the case.. it’s an AND operation..  so when setting these properties programmatically it took me a while to figure out which ones to use. But fortunately enough I managed ;)

  • ServerTemplate, the template ID of the list/document library. So 101 for Document Libraries for example
  • ContentTypeName, the name of the ContentType
  • ContentTypeBeginsWithId, the id of the Parent ContentType. Please note here, that in some cases you need to have the Parent of the Parent of the Child ContentType due the fact that when a ContentType is added to a list, it automatically is being marked as a child.

 

To conclude this post, here are some articles that helped get going:

Taking Assembly Free Solutions to the Next Level

My mate Daniel beautifully crafted a post about creating assembly free solutions by using nothing more then :

  • SharePoint Designer
  • Javascript
  • SharePoint Web Services

    Check out his post on what he has done for us so we can enter our timesheets more effectively ;)

  • Anonymous Application Pages

    I wanted to make an application page become accessible for anonymous users but I was constantly being prompted with a logon box whenever I told the the page that it should inherit from a custom class like so

    <%@ Page Language="C#" MasterPageFile="~/_layouts/simple.master" Inherits="zevenseas.ApplicationPages.CustomClass"  %>

    So what to do? Well the first thing I found that I should inherit my CustomClass from the UnsecuredLayoutsPageBase instead of the LayoutsPageBase. Secondly, by inheriting from this other page, I have gained access to the following property called AllowAnonymousAccess, which should be overriden like this:

      protected override bool AllowAnonymousAccess
      {
           get
           {
               return true;
            }
      }

    Once overridden and setting it to true, your custom application page becomes accessible for anonymous users as well ;)

    Technorati Tags:

    Seminar Invitation: Meet International and Local SharePoint Experts in Amsterdam

    Together with Quest and Microsoft, we are a part of a mini SharePoint conference here in Amsterdam that will take place on the 3rd of April. Here’s the agenda and notice that I’m actually going to co-host a sessions with none other than our very own SharePoint godfather Joel Oleson! ;) And even Mike - Mad Scientist - Watson is here and our local heroes Waldek Mastykarz and Matthijas Hoekstra are part of the team as well.

    Register Now

    http://www.quest.com/common/default.aspx?backtourl=/common/registration.aspx?requestdefid=22926

    Big thanks to Quest Software for putting it on.

    Join international and local SharePoint experts in Amsterdam and learn how to master your SharePoint environment. Sponsored by Quest Software and Microsoft.

    Date: Friday, April 3rd, 2009
    Time: 10.30 - 16.30 (Registration begins at 10.00)
    Location: Auditorium, Microsoft Netherlands (map
    Cost: Free (Lunch is included)

    Agenda:

    10:00 Registration

    10:30 Welcome and Introductions

    10:40 SharePoint Successful Deployments in 10 Steps 
    Joel Oleson, Quest Software

    11:30 SharePoint, the Social Computing Platform (Business Strategy and Adoption)
    Daniel McPherson, zevenseas

    12:30 Lunch

    1:30  SharePoint Logical and Physical Infrastructure Fundamentals  
    Joel Oleson, Quest Software & Robin Meure, zevenseas

    2:30 Backup Demystified
    Mike Watson, Quest Software

    3:30 Experts Panel and Q&A

    4:30 Wrap Up

    Meet the Experts:

    Joel Oleson
    SharePoint Expert,
    Quest Software

    Joel is a senior product manager and SharePoint evangelist at Quest where he is responsible for product direction and strategy. He is well known in the SharePoint community as an enthusiastic trainer, evangelist and architect and he maintains a popular blog. Prior to Quest, Joel worked at Microsoft and was a part of the first Microsoft global deployment of SharePoint. During his Microsoft tenure Joel helped various customers achieve the critical governance they needed to upgrade and achieve scale with SharePoint 2007. He would later design the extranet and hosted SharePoint deployments. http://www.sharepointjoel.com


    Mike Watson

    SharePoint Expert, Quest Software
    Mike Watson (MCSE, MCSA) is a senior product manager at Quest specializing in SharePoint manageability, scalability and availability. Before moving to Quest Software, Mike was instrumental in planning and deploying Microsoft Managed Services and Microsoft Online, as well as Microsoft Services efforts such as MOSSRAP (MOSS Risk Assessment Program) and SLM (Service Level Manager). http://www.sharepointmadscientist.com

    Daniel McPherson
    SharePoint Business Consultant and Co-Founder, zevenseas

    Daniel has been involved in SharePoint since attending the first public announcement of project “Tahoe” at the Microsoft Technical Briefing in January 1999. It has had a profound impact on his career, taking him to the doorstep of hundreds of companies, of all shapes and sizes, in a range of industries,and in over 25 different countries. After 10 years at Microsoft, spent mostly in Microsoft Consulting Services, he is a co-founder and business consultant. http://community.zevenseas.com/Blogs/Daniel

    Robin Meure
    SharePoint Technical Consultant, zevenseas

    Robin joined Atos Origin in 2004 and was immediately introduced to the rapidly emerging Microsoft SharePoint Products and Technologies At Zevenseas, Robin helps customers plan, deploy and build solutions on SharePoint, and participates actively in the broader SharePoint community though his blog and many contributions to Codeplex. He is a founding member of the Elite SharePoint Black Belts established by Microsoft in Holland to promote skills sharing among its partners. http://community.zevenseas.com/blogs/robin

    Matthijs Hoekstra
    Developer Evangelist, Microsoft Netherlands 

    Matthijs is a Developer Evangelist at Microsoft in The Netherlands. He joined Microsoft in 2002, worked 6.5 years as a consultant for Microsoft Services working with customers in the areas Information Worker, Portals and e-business. Matthijs mostly works with products as: SharePoint Portal Server, Windows SharePoint Services, Office, Unified Communications and .NET. http://blogs.microsoft.nl/blogs/mhoekstra


    Waldek Mastykarz
    SharePoint MVP
    Waldek Mastykarz is a Dutch SharePoint MVP specialized in Web Content Management solutions in Microsoft Office SharePoint Server 2007, web standards and accessibility. Waldek Mastykarz is a Dutch SharePoint MVP specialized in Web Content Management solutions in Microsoft Office SharePoint Server 2007, web standards and accessibility. http://blog.mastykarz.nl

    SPApplicationPool

    As always, I was wandering through the OM of our beloved SharePoint searching for getting to the Application Pools of a WebApplication. The case is that for our beloved LCM tool I was trying to get all the application pool accounts and add those to the LCM web as contributors.

    Since I came across an issue regarding the fact that when a site or a web is deleted and you’ve checked ‘Log the deletions in SharePoint’ in the configuration page. The application pool accounts couldn’t get access to the “Deleted Sites” list on the LCM Web. (btw this is still an issue and is not solved by adding the accounts to the Web. This is due to the fact that the service accounts must be added as a farm admin to the Central Admin.. and we don’t want that either ;).

    But to come back to the topic.. I’ve found an interesting class and that is the SPApplicationPool class. And.. well.. I was shocked to find out that there is a property called “Password”. Well actually I wasn’t shocked to found out that the property existed.. but I was shocked to find out that the property was not only settable but also gettable!!

    So when running the following piece of code..

    SPWebApplicationCollection webApplicationCollection = SPWebService.ContentService.WebApplications;
    foreach (SPWebApplication webApplication in webApplicationCollection)
    {            
        SPApplicationPool applicationPool = webApplication.ApplicationPool;
        Console.WriteLine("WebApplication " + webApplication.Name);
        Console.WriteLine("Username " + applicationPool.Username);
        Console.WriteLine("Password " + applicationPool.Password);
    }

    ..it will give you the passwords of each application pool account. Though I must say that this of course will only run if you logged in as a farm admin since this comes out of the SharePoint.Administration namespace. But I must say that this is quite tricky..  especially when there is another property in there called “SecurePassword”.

    Please let me know your thoughts ;)

    I’m going back to work on a different solution to store those damned deleted sites..

    Technorati Tags: ,

    Did you know..

    that SharePoint’s calendar has a hard limit of 1000 items per calendar month. and that Copied folders are not indexed ?

    No? Well neither did I but luckily we have someone in the SharePoint blog-o-sphere who does.. and that is  Itay Shakury ;)

    Thanks Itay!

     

    Technorati Tags: ,


     
     
     

    © 2009 Community Kit For SharePoint