Wednesday, August 19, 2009

BizTalk: Create dynamically nodes with mapper and looping

Problem:
Sometimes, we receive data as input, but need to split this data in the output.
Ex. As Input we receive 2 dates, begin-date and end-date.
The output should be for every date between the given dates 1 node

Input Data
Begin Date: 19-8-2009
End Date: 25-8-2009

Output Data
19-8-2009
20-8-2009
21-8-2009
22-8-2009
23-8-2009
24-8-2009
25-8-2009

Our customers always used an external web service to do this or a C# class (placed in the GAC). I was wondering if it would be possible to do the same 100% out of the ox, so when we deploy we don’t need to care of the extra class in the GAC or web services and security.

Solution in BizTalk

1. Create Input Schema




2. Create Output Schema



3. Create Mapping



Source Schema: InputSchema

Destination Schema OutputSchema



Script 1: This script is an inline C#, calculating the different days between the begin date and the end date. The script returns an integer.

public int SubtractDates(System.String param1, System.String param2)
{
System.TimeSpan diffresult = System.Convert.ToDateTime(param2) - System.Convert.ToDateTime(param1);
return diffresult.Days;
}


Script 2: Select Inline XSLT Call Template. The XSLT template is recursive. The first part is handling the receiving parameters. The second part is the creation of a node in the output schema (). The third part, we call the same XSLT template, with the updated variables

Pay attention on the last parameter startDate, we call a inline CSharp Function (see further)

The reason why we need to call an inline CSharp function is the fact that BizTalk handles only XSLT 1.0, so we can’t use some great date time functions.
(the lines starting with ------ must be deleted, it is just to explain the different parts of the code)

------ Parameters --------






------ Creation of a node --------








------ recersive Part --------

















Script 3: This script functoid has no input or output parameters, but we create Inline C# function, AddDaysToStartDate. The function will just add a number of days to the given start date. (Parameters coming from script 2)

public System.DateTime AddDaysToStartDate(string param1, string param2)
{
DateTime _date = System.Convert.ToDateTime(param1);
return _date.AddDays(System.Convert.ToDouble(param2));
}

Test the mapping and you will see that the output schema contains an interval node for everyday between begin and end date.

Monday, June 15, 2009

Silversands Associates iPhone ready

The website of SilverSands Associates is adapted to have a real iPhone experience, when surfing to the website with an iPhone.

Have a look.
From the iPhone: SilverSandsAssociates.com

iPhone1

Filter SharePoint List by Workflow Status

Often we need to filter a SharePoint list by  the status of a workflow.

This is rather simple and can be done in the same way as filtering any other field.

The only thing you need to know is that the status of the workflow is an integer, not a text.  So we can’t add a filter like ‘Workflow name’ IS EQUAL TO ‘In Progress’

The following list gives the integer values of each status.

  • 0 - Starting
  • 1 - Failed on Start
  • 2 - In Progress
  • 3 - Error Occurred
  • 4 - Canceled
  • 5 - Completed
  • 6 - Failed on Start (retrying)
  • 7 - Error Occurred (retrying
  • 15 - Canceled
  • 16 - Approved
  • 17 - Rejected
  • Prepare your InfoPath for deployment and be sure your form is generic

    When creating an InfoPath form, we often use the data connections.
    InfoPath makes it easy to work with data connections, but the issue is that the links to the SharePoint library or database is saved in the InfoPath Form.

    What if we have to move the SharePoint Library to another place?
    Ex. Test -> Production Environment

    What if we change the name of the SharePoint Library we want to submit too?

    We can’t always return to our InfoPath Designer, make the changes and publish again.

    Happily for us, InfoPath 2007 with SharePoint has a solution.  SharePoint offers a Data Connection Library.
    Within the data library we place our InfoPath Data Connections.  When changing database password, changing SharePoint Library names or paths etc we just change the Data Connection file in the Data Connection Library and your InfoPath will continue working.

    The next part will explain you step by step how to do this.

    To Create a SharePoint Data Connection Library if the library does not yet exists.

    1. Browse to an Office SharePoint Server 2007 or Office Forms Server 2007 site on which you have at least Design rights. If you are on the root site, or portal, go to the Document Center or create a new site before proceeding to the next step.

    2. Click Create on the Site Actions menu.

    3. On the Create page, click the Data Connection Library link in the Libraries section.

    4. On the New page, type a name for the library and click the Create button.

    5. Copy the URL of the new library.

    Update your InfoPath file

    1. Create a data connection in InfoPath, following the wizard

    2. After creating the data connection, you see the list of data connection.

    Select the newly created data connection

    3. Click on Convert

    4. On the Convert Data Connection dialog box, enter the URL of the data connection library that you previously copied.

    5. Delete "Forms/AllItems.aspx" in the URL.

    6. Enter a name for the data connection file at the end.

    7. Click OK.

    8. Confirm that the data connection has been converted successfully by examining the Details section of the Data Connections dialog box while the converted data connection is selected.

    Don’t forget to publish your InfoPath Form.

    You will see that under the Data Connections Library, a new file is added.  This file needs to be updated when moving environments, changing databases, changing submit libraries etc.

    Prepare your InfoPath for deployment and be sure your form is generic

    When creating an InfoPath form, we often use the data connections.
    InfoPath makes it easy to work with data connections, but the issue is that the links to the SharePoint library or database is saved in the InfoPath Form.

    What if we have to move the SharePoint Library to another place?
    Ex. Test -> Production Environment

    What if we change the name of the SharePoint Library we want to submit too?

    We can’t always return to our InfoPath Designer, make the changes and publish again.

    Happily for us, InfoPath 2007 with SharePoint has a solution.  SharePoint offers a Data Connection Library.
    Within the data library we place our InfoPath Data Connections.  When changing database password, changing SharePoint Library names or paths etc we just change the Data Connection file in the Data Connection Library and your InfoPath will continue working.

    The next part will explain you step by step how to do this.

    To Create a SharePoint Data Connection Library if the library does not yet exists.

    1. Browse to an Office SharePoint Server 2007 or Office Forms Server 2007 site on which you have at least Design rights. If you are on the root site, or portal, go to the Document Center or create a new site before proceeding to the next step.

    2. Click Create on the Site Actions menu.

    3. On the Create page, click the Data Connection Library link in the Libraries section.

    4. On the New page, type a name for the library and click the Create button.

    5. Copy the URL of the new library.

    Update your InfoPath file

    1. Create a data connection in InfoPath, following the wizard

    2. After creating the data connection, you see the list of data connection.

    Select the newly created data connection

    3. Click on Convert

    4. On the Convert Data Connection dialog box, enter the URL of the data connection library that you previously copied.

    5. Delete "Forms/AllItems.aspx" in the URL.

    6. Enter a name for the data connection file at the end.

    7. Click OK.

    8. Confirm that the data connection has been converted successfully by examining the Details section of the Data Connections dialog box while the converted data connection is selected.

    Don’t forget to publish your InfoPath Form.

    You will see that under the Data Connections Library, a new file is added.  This file needs to be updated when moving environments, changing databases, changing submit libraries etc.

    Tuesday, May 19, 2009

    Another Office Tip: Format painter (Office)

    FormatPainter The Format Painter tool replicates the formatting from one part of a document to another. So instead of manually redoing all the formatting yourself, you can use the Format Painter.

    1. select the text whose formatting you want to replicate.

    2. click the Format Painter toolbar button.
    3. select the text you want to imbue with the format.

    For bonus points,
    1. select the text whose formatting you want to replicate

    2. double-click the Format Painter toolbar button.
    3. select the multiple texts you want to imbue with the format

    Source: http://office.Microsoft.com

    Tuesday, May 5, 2009

    Business Rule Engine and Static .net Classes

    When using static classes together with the Rule Engine you will get an error when testing the policy

    Fact unrecognized.

    The solution is explained in the following link, in a few words,Business Rule Engine needs an instance of a class and don’t know how to work with Static classes but by changing a parameter it can be solved.

    http://geekswithblogs.net/cyoung/articles/111169.aspx


    Thanks to Jean-Francois Philagor for pointing this article.