In The Mix

As a SharePoint architect I have the business behind me and the Developers and IT Pro on my shoulders.

Info Path Task Forms Made Easy October 28, 2008

Filed under: SharePoint — fmuntean @ 8:43 am

[Update November 2009] A follow up post with source code, demos and instructions for this approach is available here: https://fmuntean.wordpress.com/2009/11/27/infopath-task-forms-made-easy-part-2/

If you are using an InfoPath library there is a very easy and safe way to work with the xml InfoPath generated data.

You get and set data on the item is by using xml de/serialization as shown in the next snippet:

SPItem item = ....
YourInfoPathFormClass yourForm;
XmlSerializer serializer = new XmlSerializer(typeof(YourInfoPathFormClass));
using (Stream stream = item.File.OpenBinaryStream())
{
        yourForm = serializer.Deserialize(stream) as YourInfoPathFormClass;
}

Now YourInfoPathFormClass is generated using the xsd utility from the InfoPath Form xsd files: xsd.exe YourForm.xsd /c /namespace:YourNameSpace

When it comes to the Workflow and InfoPath Task Forms, this easy and type safe way does not work. Microsoft decided to use a rather complicated and convoluted mechanism to pass data between Workflow and the InfoPath Task Form. So you find yourself building helper classes with lots of lines just to encapsulate the strings used inside the Task Form. For simple Task Forms this is not a big problem but it will be if your Workflow has many complicated Task Forms. Another problem that you will face is the inability to use complicated types inside Task Forms because the Extended Properties contains a flat list of key value pairs.

I would like to be able to use the first approach for Task Forms too. All I needed is for Microsoft to have passed the InfoPath xml data as an Extended Property and I would be able to de/serialize my Task Form data in xml format inside that Extended Property.

So again I put my "Reverse Engineer" Hat on and start looking at how Microsoft built the interface between InfoPath and SharePoint Workflow Task Forms.

Following are my findings:

A content type is used to differentiate between the OOB Task Forms and the InfoPath ones. A ItemMetadata xml file is used to transfer data between the InfoPath Form and SharePoint. The WrkTaskIP.aspx inside _Layouts is the page that contains the InfoPath XMLFormControl that displays the InfoPath Form and controls the data flow between the Task and SharePoint. For more info on InfoPath Tasks Forms read the following MSDN article: http://msdn.microsoft.com/en-us/library/ms497641.aspx?ppud=4

Having all this information now we can modify the way that we send and receive data from the InfoPath Task Forms:

1. Create a new Content Type that derives from the InfoPath Content Type and uses a different WrkTaskIP.aspx page.

2. Copy the WrkTaskIP.aspx page under the same name that you have used in the custom Content Type and modify the copy to implement the page from a custom class.

3. Create a Custom Class that derives from  WrkTaskIPPage and add the following references: Microsoft.office.InfoPath.Server, Microsoft.Office.Workflow.Pages (you can found this in the _app_bin folder), Microsoft.SharePoint,System.Web, System.Xml

4. Now in the custom class we will need to override the following events using the OnInit method as shown in the following snippet:

protected override void OnInit(EventArgs e)
{
     base.OnInit(e);
      base.XmlFormControl.Initialize -= new EventHandler<InitializeEventArgs>(base.XmlFormControl_Initialize);
      base.XmlFormControl.Initialize += new EventHandler<InitializeEventArgs>(this.XmlFormControl_InitializeNew);
       base.XmlFormControl.Close -= new EventHandler(this.XmlFormControl_OnClose);
       base.XmlFormControl.Close += new EventHandler(this.XmlFormControl_OnCloseNew);
} 

5. You will be sending data to the InfoPath form in the InitializeNew and get data from the InfoPath form in the OnCloseNew methods.

6. Personally I chose to use "IPFormDataXML" as a key in the Extended Properties to pass data back and forth.

7. Make sure that you build everything as a SharePoint solution.

Now to work with the InfoPath Task Form all we need is to again generate the classes from the Task From xsd schema and de/serialize data in the Extended Properties (make sure that you now specify your content type  inside the workflow.xml file for the TaskListContentTypeId attribute.

For more info drop me a line.

 

How to Configure IIS SMTP Server to forward emails using a Gmail account October 26, 2008

Filed under: SharePoint — fmuntean @ 8:03 pm

This is very useful when you want to test your outgoing email for SharePoint but not have access to an SMTP server.

  1. Create and setup a Gmail account to use POP3.

    Enabling POP3 in Gmail: http://mail.google.com/support/bin/answer.py?answer=13273&cbid=wl8yzeug2lob&src=cb&lev=topic

  2. Install the mail server role (POP3 and SMTP) 
  3. Configure the IIS Server to forward messages using that account:
    1. IIS SMTP Virtual server -> Properties ->
      1. Access Tab

    clip_image001

    1. Relay Button

    clip_image002

    You can specify only the servers that you want to be able to send email here by selecting Only the list below and adding your servers IP addresses.

    1. Delivery Tab

    clip_image003

    1. Outbound Security Button:

    clip_image004 
    Select Basic Authentication and specify your Gmail account  and password. Check the TLS encryption.

    1. Outbound connections button

    clip_image005
    Set TCP port to 587.

    1. Advanced Button

    clip_image006
    specify the smart host as smtp.gmail.com

  4. Now configure the Outbound email in SharePoint to send email to the server where you have installed this SMTP server.
 

RePDC 2008 October 15, 2008

Filed under: Uncategorized — fmuntean @ 9:59 pm

Today Bob Familiar announced at MSDN Road Show in Waltham that on January 22nd 2009 the best of PDC 2008 will be arriving in Boston. So if you are like me and can’t make it there this year make sure that you mark the calendar for this great event.

Thank you Bob for your hard work on putting this together and make it happens. I really enjoyed the ReMIX07 and I am looking forward to it.

 

Silverlight 2.0 just released

Filed under: Silverlight — fmuntean @ 9:50 pm

The version 2 of the Silverlight was just released yesterday.

Get it from here: http://www.microsoft.com/silverlight/

To start developing: http://silverlight.net/GetStarted/

Note: Make sure that you have installed Visual Studio 2008 SP1.

 

My first CodePlex Project October 3, 2008

Filed under: Uncategorized — fmuntean @ 8:54 pm

I am already using this application for a while now.

I just released a Sharepoint Site Collection Backup utility on Codeplex.

Please take a look at: http://www.codeplex.com/SPSitesBackup

I find this utility very usefull if you have multiple site collections in your farm.

You can use it for MySites to keep a backup of each separatelly. and then when you need to restore one you can restore just the one for the user that requested it. You can even use this for the outboarding process (just keep a copy of the user personal site and delete the site from the Farm).

However I want to stress that you will still need to have a full farm backup because this utility is not a replacement for that.

If your application contains multiple projects each on a separate site collection (my recomandation) then you can use this utility to archive them separatelly.

If you find this usefull please leave me comment and tell me how you are using it.