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.

    Tuesday, April 28, 2009

    Another Office Tip: World Clocks in Windows Vista


    Within the section of “Another Office Tip” I will give some tips, ideas how to get the maximum out of your Windows products and help you to make working easier.


    When working in an international environment, time zones are important as you don’t want to wake up you business partner to early :)

    There are many world clock tools available on the net, but always you need to install these programs, it takes more place on your desktop etc.

    This is a tip for Vista users, Windows Vista has a feature to show 2 extra clocks in the taskbar;  You will always see the current local time and by clicking on the time you will get the others clocks in a visual way.

    image

    By position your mouse on the time, without clicking, you will get a simple list

    image

    How to setup different clocks in Vista?

    - Go to Control Panel
    - Select Date & Time
    - Select the tab: Additional Clocks
    - Choose the clocks you like to add and give it a name.

    Monday, March 30, 2009

    SQL Adapter – Generating a Schema

    When using the Stored Procedures in SQL Server and BizTalk, we need to add the XSD to the project.  When using the Add Adpater MetaData feature of BizTalk (Add –> Add Generated Items…) BizTalk generates the schema, but the result is equal to the Success element and is of atype  AnyType.

    This behavior is not the one we want as we want to use the return values.

    Solution:

    1. First create the Store Procedure
        ex. SELECT Id, Name FROM Countries FOR XML AUTO, XMLDATA

       Be sure to add FOR XML AUTO, XMLDATA at the end.

    2. Run the Add Adapter MetaData wizard, within Visual Studio and your   
        BizTalk Project.

    3. At the Statement Information screen, you need to enter valid values
        into the Value column

    4. Click the Generate button

    5 Finish the Wizard, you will see that now the XSD will contain the

       structured results and not anymore the AnyType element.

    6.  After the XSD is generate, remove the XMLDATA clause from the
         Stored Procedure;
        ex. SELECT Id, Name FRO Countries FOR XML AUTO

    Wednesday, March 25, 2009

    FileUpload control within an Update Panel

    The FileUpload control is not working within the Update Panel control, but there is a workaround:

    Add the following code to the Page_Load event of your page:

    ScriptManager.GetCurrent(Page).RegisterPostBackControl(cmdUploadPicture);

    Where cmdUploadPicture the ID of button is, used to Upload the File.

    Tuesday, March 24, 2009

    Cascading Drop downs in InfoPath Web Forms made easy

    To create user‐friendly web forms, cascading drop down list boxes is a must, but InfoPath Form Services doesn’t allow you to use them, like you can use them with InfoPath Client.
    (Filter Data on DataConnections/DataSources are not allowed with InfoPath Web Forms)

    This article explains how to use Cascading


    http://www.silversandsassociates.com/HOW_TO_use_Cascading_Dropdown_ListBoxes_within_an_InfoPath_Web_Form.pdf

    (Silversands Associates is very happy that already hundreds of companies used this article to get cascading dropdown list boxes into there web based InfoPath forms)

    10 Rare HTML Tags You Really Should Know

    When working in IT, we often come across the good old HTML.  I found a very interesting article about rare HTML tags, written by Glen Stansberry.

    http://net.tutsplus.com/articles/web-roundups/10-rare-html-tags-you-really-should-know/

    Monday, February 9, 2009

    Naming Conventions

    The raison to write this article is because I still see many multi-nationals struggling with naming conventions within their IT department.

    Naming conventions are as old as IT itself, but still many companies do not have proper naming conventions, and even worse, they use internal of external sources to create one.

    What is the reason to have Naming Conventions in the first place?
    The main reason to introduce naming conventions is to :

    • - to reduce the effort needed to read  and understand source code
    • - to enhance source code appearance

    The most important reason is the first one, to reduce the effort needed to read and understand source code

    Code must be easy and quick readable and understandable when new employees (internal of external) enters the IT department or when other teams takes over the project..

    The answer I gave to my customers is very easy: take the naming conventions found on the Internet.  The goal is not only to have company related Naming conventions, but general naming conventions.

    New employees or external consultancy will loose less time understanding the general naming conventions, as they were used too with their previous work, instead of learning the company related ones, which will never be followed 100%.

    Some links:

    BizTalk: http://wes.fehler.ca/weblog/biztalk/2005/01/biztalk-naming-conventions.html

    General Naming Conventions: http://msdn.microsoft.com/en-us/library/ms229002.aspx

    And many more are available on the net. 

     

    Don’t let your IT department loose time to write company related naming conventions, re-use them!