Sunday, April 29, 2007

Repair.aspx can't get to the message

In the current project I am working on, there is a need to move some InfoPath forms from one Sharepoint library to another while preserving the information contained in them. The one caveat to this, is that one of the requirement is that we need to modify a couple of fields inside the infopath forms.

In summary these are the tasks that I need to accomplish:
  • Modify the PI (Processing Instructions) for each form in Sharepoint so that they point to the correct template library.
  • Modify some of the data inside of the Infopath forms (since the data is contained inside the Infopath). This includes updating and adding a couple of nodes.
These fields are then used by Biztalk when routing the document to another Sharepoint library. I have tried several approaches.

A. Repair.aspx. This form is found inside the FORMS folder on your Sharepoint library. It does fix the hardcoding href command found on the PI (Processing Instruction) for the InfoPath forms. It will accomplish one of my goals, however the user interface is not the most friendly. For instance, one of the source library location, have over 1500 forms. If you decide to use the Repair.aspx, that's a lot of clicking you got to do..!!

B. Microsoft repair download tool for infopath 2007. This tool can be download here. This is pretty much the EXE version of the repair.aspx. It is called: IPWssUpg.exe. It goes s and change the hard coded values of the InfoPath forms to the current location. This is mainly used when you are moving to a new server, or copying forms to a new library, etc. This tool can accomplish Task 1, but it wont be able to modify the actual content which is what I am after in Task2.

C. Write a .NET component to parse the Sharepoint lists and then load the whole Infopath as an XML file and apply regular expressions to accomplish Task 1 and 2. Lazy.

D. Use Biztalk to do it. Since we already have Biztalk 2006 deployed on the environment, it can be put to good use. ;)

E. Powershell?. maybe, but I don't have the time to learn it right now.

Enter Biztalk 2006. In just 7 lines of code I can accomplish both Task 1 and Task 2. By using the Windows Sharepoint Service Adapter (WSS).

First, setup a basic orchestration:

then on the Message Constructor, add the following lines:

Add Updated PI

1 //Messages are immutable.

2 outMsg = inMsg;


4 //populate the new infopath PI

5 sInfopathPI = @"< ?mso-infoPathSolution PIVersion='' href='some_XSN_Path'? > ....";


7 //issue the command

8 outMsg(XMLNORM.ProcessingInstructionOption) = 1;

9 outMsg(XMLNORM.ProcessingInstruction) = sInfopathPI;

WSS Instructions

1 //set the filename for target location

2 outMsg(WSS.Filename) = strFilename + ".xml";

BTS Instructions

1 //if a form document is found on the library, overwrite it.

2 outMsg(WSS.ConfigOverwrite) = "yes";

3 outMsg(WSS.ConfigOfficeIntegration) = "no";

Make sure that both the receiving and sending logical ports are setup to Specify Bindings Later.
Then using the Biztalk Administrator console, configure a Receive Location and a Send Port to use the WSS adapter, put the values for the Sharepoint Library (both source and target locations)

Bind the physical ports to the logical ports, and the ODX will pick the forms from the source library and move them to the target location.

7 lines of code!!! Can't get any lazier than that.. ;)


Anonymous said...

Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!

Alex said...

Corrupted or lost mdf files may be resolved due to repair mdf file. It can work with big .mdf files, works under any MS Windows. The application can show restored mdf data from any version of SQL Server, it uses modern ways of repairing .mdf.