Saving Forms as New to DBXL - Jimmy Rishe
in

InfoPath Dev

Jimmy Rishe

Saving Forms as New to DBXL

Typically when you open a form from DBXL and re-submit it, your modified form will be saved on top of the one you opened.  This is a very useful feature, and undoubtedly what you want to do most of the time, but sometimes you will want to save a new copy of a form and leave the original one unchanged.  This short tutorial will teach you how to do that.

The DBXL PI

When you open a form from DBXL, the form's XML will have an XML Processing Instruction (PI) embedded in it.  This PI contains the form's DocId, and some other information, and when you re-submit the form, DBXL reads this and knows which form to overwrite.

Therefore, if you remove this PI, DBXL will treat the form as a new document, and will save it as a new form, instead of overwriting the original.  Below are two methods for removing this PI.

Using qRules

qRules includes a command to remove the DBXL PI from an XML form. Just use this simple command:

              RemoveDbxlPi

Using Code

If you would prefer to use code, you can use the following short snippet to locate the DBXL PI, and remove it if it is present:

const string piXPath = "/processing-instruction()[name() = 'QdabraDBXL']";
XPathNavigator pi = MainDataSource.CreateNavigator().SelectSingleNode(piXPath);

if (pi != null)
{
        pi.DeleteSelf();
}

Once you have used one of the two above methods, your form should be submitted as a new document the next time you submit it.

Comments

 

ZhenYuan said:

Hi Jimmy,

I tried using your code method but my forms are still submitted as a new version instead of as a new docid. I placed the code below on my form's loading event and then opened a submitted form from DBXL and resubmitted the form. The end result was the newly submitted form was submitted as a new version of the original docID. Did I miss out anything?

My code:

           Dim piXPath As String

           Dim pi As XPathNavigator

           piXPath = "/processing-instruction()[name() = 'QdabraDBXL']"

           pi = Me.MainDataSource.CreateNavigator()

           Try

               pi.SelectSingleNode(piXPath, Me.NamespaceManager).DeleteSelf()

           Catch delDOCID As Exception

               Return

           End Try

December 8, 2010 6:57 PM
 

Patrick Halstead said:

Hi ZhenYuan and sorry for missing this. If you are using qRules, we have a command called RemoveDBXLPI which will also do this.

May 12, 2011 1:55 AM
Copyright © 2003-2012 Qdabra Software. All rights reserved.
View our Terms of Use.