June 2010 - Posts - Aruna Akella
in

InfoPath Dev

Aruna Akella

June 2010 - Posts

  • How to use the InsertPi and RemovePi command

    New for qRules v2.2 -- InsertPi and RemovePi (processing instructions)

    Why is this useful? 

    • Change the href attribute of the mso-infoPathSolution PI so to submit to a different SharePoint library and have the form open using the template for that library
    • For DBXL users, RemovePi to easily make a copy of a filled out document

    The InsertPi command inserts the specified PI into the DOM while the RemovePi command removes the specified PI from the DOM, if present.

     InsertPi Arguments:

    • name: Name of the processing-instruction to insert.
    • data: Data content of the processing-instruction.
    • update: (optional) Update the processing-instruction if it already exists (yes | no*).
    • dsname: (optional) Data source to insert the processing instruction.

    InsertPi Examples:

    • InsertPi /name=Test /data=dev=”false”
    • InsertPi /name=Test /data=dev=”false” /dsname=QdabraRules
    • InsertPi /name=Test /data=dev=”false” /dsname=QdabraRules /update=yes
    • concat("InsertPi /name=", name, " /data=", data, " /dsname=", dsname, " /update=true")

    RemovePi Arguments: 
     

    • name: Name of the processing-instruction to remove.

    RemovePi Examples:

    • RemovePi /name=Test


    PRE-REQUISITE

    This tutorial assumes that you already have qRules v2.2 or later installed on your machine. For details on this, please see the User Guide included with the installer.

    1. Create a new InfoPath form: In InfoPath, design a new, blank form. Select File > Save As and save the XSN to your local drive. Close the form.
    2. Launch the qRules v2.2 Injector, browse to select the XSN you created and click Inject. Close the qRules Injector and open the form in Design mode.

    For more information on the steps above, refer to the User Guide.

    EXECUTION STEPS

    Design your form template based on the following steps:

         1.  Your main data source should be similar to the below one:

                
         2.  Drag and drop the data source nodes onto your form canvas, so you have something like this:

               
         3.  Click on the InsertPi button, and then from Home > Add Rule > When This Button is Clicked > Set a Field’s Value:

                
         4.  Set the value of the QdabraRules(Secondary) Command field.

                 
       

         5.  Set the command value to the InsertPiCommand field from the main data source and click OK.

               
        

          6.  Right click on the InsertPiCommand, and select Text Box Properties… and enter the value:
                       InsertPi /name=Test /data=dev=”false”

                
         7.  Click OK.

         8.  Click on the RemovePi button, and then from Home > Add Rule > When This Button is Clicked > Set a Field’s Value:

         9.  Set the value of the QdabraRules(Secondary) Command field again, this time, however....

         10. For the value, click on the fx button, and add the below formula (Note: name points to the name field from the main data source).
                     concat("RemovePi /name=", name).

                
          11. Your final action  should look similar to the below one:

               
          12. Click OK.

          13. Now drag and drop the QdabraRules Result, Success, and Error fields into the view.

          14. Preview the form.

          15. Click InsertPi button to execute the InsertPi command.

              
          16. Save, and close the form, and open the XML in a text editor to view the inserted processing instruction.

          17. Next test removing a PI.

          18. Enter an existing PI name in the Name field (this tutorial uses Test).

          19. Click RemovePi button to execute the command.

             

          20. Now save, and close the form and open the saved form in a text editor to see the removed processing instruction. 

          21. You can also use a concat command if you wish to use specific fields with dynamic values in your InsertPi command parameters. Let’s replace InsertPiCommand field with a concat command.

                  a. In design mode, right click on InsertPiCommand field, and select Text Box Properties… to set the value to the below concat command (Note: Since concat is an InfoPath function, you will have to enter it as a formula, pointing name, and data, to  their respective nodes in the main data source:
                                       concat("InsertPi /name=", name, " /data=", data, " /update=true")

                               
                  b. Preview your form.

                  c.  Enter Test in the Name field, and dev=”false” in the Data field.

                             
                  d. Click InsertPi button.

                             
                  e. Now save, and close the form and open the saved form in a text editor to see the inserted processing instruction. You should see a PI similar to the below one.
                                      <?Test dev="false"?>

          22. Similarly you can also insert a processing instruction to a secondary data source using /dsname parameter:

                 a. In the design mode, right click on InsertPiCommand field, and select Text Box Properties… to add a new parameter to the InsertPi command. Your command should look similar to the below one:
                                      concat("InsertPi /name=", name, " /data=", data, " /dsname=", dsname, " /update=true")

                             

                 b. Save and preview the form.

                 c. Enter data in the fields as shown below (this tutorial uses QdabraRules as a secondary data source).

                             
                 d. Click InsertPi button.

                                 
                 e. Now the PI is inserted to QdabraRules data source (Note: You can verify that by having an expression box with the following value: xdXDocument:GetDOM("QdabraRules")/processing-instruction()[local-name(.) = "Test"]

     

  • How to use the GetAttachmentAttribute command

    New for qRules v2.2 -- GetAttachmentAttribute! 

    Why is this useful?

    • Promote the name of the attachment in a form to a form library, by getting the file name and copying it into a main data source node
    • Send information about form attachments in an email submit to users

    This command extracts the details of an attachment, including file name, extension, and size.

    Arguments:

    • xpath: Xpath to field to Decrypt.
    • attr: Specific attribute value to get (Name | Ext | Size | File).
    • dsname: (optional) Data source name.

    Examples:

    • GetAttachmentAttribute /xpath=/my:myFields/my:FileAttachment  /attr=Name
    • GetAttachmentAttribute /xpath=/my:myFields/my:FileAttachment  /attr=Ext
    • GetAttachmentAttribute /xpath=/my:myFields/my:FileAttachment  /attr=Size
    • GetAttachmentAttribute /xpath=/my:myFields/my:FileAttachment  /attr=File
    • GetAttachmentAttribute /xpath=/my:myFields/my:FileAttachment  /attr=Name /dsname=<SECONDARY DATASOURCE>

    PRE-REQUISITE

    This tutorial assumes that you already have qRules v2.2 or later installed on your machine. For details on this, please see the User Guide included with the installer.

    1. Create a new InfoPath form: In InfoPath, design a new, blank form. Select File > Save As and save the XSN to your local drive. Close the form.
    2. Launch the qRules v2.2 Injector, browse to select the XSN you created and click Inject. Close the qRules Injector and open the form in Design mode.

    For more information on the steps above, refer to the User Guide.

    EXECUTION STEPS

    Design your form template based on the following steps:
           1.   Drag and drop a file attachment control, a drop-down list box, a text box, and a button onto your canvas. Your main data source should be similar to the below one:

                    
           2.   You will have a layout similar to the one below on your canvas:

                
           3.   Click GetAttachmentAttribute button, and then from Home > Add Rule > When This Button is Clicked > Set a Field’s Value:

                
           4.   Now set the Field value to point to the QdabraRules (Secondary) Command field.

                       
           5.   Set a Value: to point to the GetAttachmentAttributeCommand field from the main data source. Click OK.

                     
           6.   Right click on the GetAttachmentAttributeCommand, and select Text Box Properties… and enter the value:
                           GetAttachmentAttribute /xpath=/my:myFields/my:FileAttachment /attr=Name

                     

           7.   Click OK.

           8.   Now drag and drop the QdabraRules Result, Success, and Error fields into the view.

           9.   Preview the form.

           10. Attach a file or a picture in a file attachment control.

           11. Click GetAttachmentAttribute button to execute the command.

                       
           12. You will see the file or picture name in the result field.

           13. Change the /attr param to Ext, Size, or File and click the button again to obtain a different attribute.

           14. Similarly you can also get specific attributes of a file attachment from a secondary data source using /dsname parameter.

           15. You can also use a concat command if you wish to use specific fields with dynamic values in your command parameters. Let’s replace GetAttachmentAttributeCommand field with a concat command.

           16. In design mode, right click on GetAttachmentAttributeCommand field, and select Text Box Properties… to add a new parameter to the command. Your command should look similar to the below one:
                          concat("GetAttachmentAttribute /xpath=/my:myFields/my:FileAttachment  /attr=", AttributeValue)

                     
           17. In the AttributeValue dropdown box, add four entries as shown below:

                    
           18. Save and preview the form.

           19. Attach a file or a picture in a file attachment control.

           20. Select one of the attribute values from the dropdown list.

           21. Click the GetAttachmentAttribute button.

                   

  • How to use the DelimitedList command

    New for qRules v2.2 -- DelimitedList!

     Why is this useful?

    • Hate trying to understand the syntax of the double eval method?
    • Need to have data from a repeating field rolled up into another field?

    This command can replace the double eval method, as it concatenates a repeating field into a single delimited value. Unlike the double eval method, however, qRules can use filtered XPath to select only certain fields from the repeating data source!

    Arguments:

    • xpath: Xpath for field with values.
    • Dsname: (optional) Data Source Name.
    • separator: (optional) List separator.
    • space: (optional) Before|After|Both..

    Examples:

    • DelimitedList /xpath=/my:myFields/my:DelimitedTextFld
    • DelimitedList /xpath=/my:myFields/my:DelimitedTextFld /separator=& /space=before
    • DelimitedList /xpath=/my:myFields/my:DelimitedTextFld /separator=& /space=after
    • DelimitedList /xpath=/my:myFields/my:DelimitedTextFld /separator=& /space=both
    • DelimitedList /xpath=/my:myFields/my:DelimitedTextFld /separator=& /space=both /dsname=<SecondaryDataSource>

    PRE-REQUISITE

    This tutorial assumes that you already have qRules v2.2 or later installed on your machine. For details on this, please see the User Guide included with the installer.

    1. Create a new InfoPath form: In InfoPath, design a new, blank form. Select File > Save As and save the XSN to your local drive. Close the form.
    2. Launch the qRules v2.2 Injector, browse to select the XSN you created and click Inject. Close the qRules Injector and open the form in Design mode.

    For more information on the steps above, refer to the User Guide.

    EXECUTION STEPS

    Design your form template based on the following steps:

    1.   Drag and drop the following controls onto your canvas, all of data type string.
           a. Bulleted List (this tutorial uses DelimitedTextFld).
           b. Text Box (this tutorial uses DelimitedCommand).
           c. Button (this tutorial uses DelimitedList).
       

          Finally you will have the following layout on your canvas:

                
    2.   Click on the DelimitedList button, and then from Home > Add Rule > When This Button is Clicked > Set a Field’s Value:

                   

    3.   Now set a Field: value to point to the QdabraRules(Secondary) Command field.

                   
    4.   Set a Value: to point to the DelimitedCommand field from the main data source. Click OK.

                 
    5.   Right click on the DelimitedCommand, and select Text Box Properties… and enter the value:
                  DelimitedList /xpath=/my:myFields/my:DelimitedTextFld /separator=& /space=before
                     

    6.   Click OK.

    7.   Now drag and drop the QdabraRules Result, Success, and Error fields into the view.

    8.   Preview the form.

    9.   Enter a delimited text:

                       
    10. Click DelimitedList button to execute the command.

                   
    11. Similarly you can also take a repeating field from a secondary data source to return a single value of the field separated by a chosen separator using /dsname parameter.

          For example:
             a. Let’s save the preview mode of the form at step10 locally.

             b. Click Data > Data Connections.

             c. Click Add… button to add a receiving data connection.

             d. Select XML document as source of your data.

                             
             e. Click Next.

             f.  Navigate to the xml file saved at step a.

             g. Click Next.

             h. Select Include the data as a resource file in the form template or template part.

                                
             i.  Click Next.

             j.  Click Finish.

                              
             k. Right click on the DelimitedCommand, and select Text Box Properties… and enter the value:
                       DelimitedList /xpath=/my:myFields/my:DelimitedTextFld /separator=& /space=before /dsname=sampleform

             l.  Drag and drop the DelimitedTextFld from sampleform secondary data source onto your canvas.

             m.Click Preview.

             n. Click DelimitedList button.

             o. The result field returns a single return value (from a secondary data source) by a chosen separator.

                        

  • How to use the ClearErrors command

    New for qRules v2.2 -- ClearErrors!

    Why is it useful?

    • Add a "save" function to your form that allows submitting with validation errors (an InfoPath impossibility!)
    • Save time when testing by not having to fill out all required fields in a form to submit (or figure out why a formula is producing an invalid value)

    This command deletes the error collection, and it is useful when submitting an incomplete form. However, note that InfoPath provides no way to restore the error collection other than closing and reopening the form.

    PRE-REQUISITES

    This tutorial assumes that you already have qRules v2.2 or later installed on your machine. For details on this, please see the User Guide included with the installer.

    1.  Create a new InfoPath form: In InfoPath, design a new, blank form. Select File > Save As and save the XSN to your local drive. Close the form. 
    2.  Launch the qRules v2.2 Injector, browse to select the XSN you created and click Inject. Close the qRules Injector and open the form in Design mode.

    For more information on the steps above, refer to the User Guide.

    This tutorial also assumes that user has configured a Submit button, which uses SubmitToSharePointList qRules command. Please refer this blog post to learn more about this command.

    EXECUTION STEPS

    Let’s discuss ClearErrors command with an example. Design your form template based on the following steps:

    1.  Your main data source should be similar to the below one (Note: Name field cannot be blank).


     
    2.  Drag and drop the above created controls onto your canvas. You will have a layout similar to the one shown in the screenshot below.
     
     3.  Click on the ClearErrors button, and then from Home > Add Rule > When This Button is Clicked > Set a Field’s Value:

     4.  Now set the Field value to point to the QdabraRules(Secondary) Command field.


     
     5.  Set the Value: to ClearErrors. Finally the rule should look similar to that shown below:


     

     6.  Click OK.

     7.  Now drag and drop the QdabraRules Result, Success, and Error fields into the view.

     8.  Preview the form.

     9.  Enter data in the Date, and Purpose field as shown below, and click Submit button.


     10. You will notice a validation error in the Error field, because there is no data in the Name field.


     
     11. Now click ClearErrors button to delete the error collection, and click Submit button again. This time you will notice that the form is published to a SharePoint library.

     

  • New documentation for Qdabra's Excel to XML Tool

    Qdabra's Excel to XML tool, available on Qdabra.com, allows you to export row data (in Excel) to XML files.

    Did you know the tool also allows you to export XML files directly to SharePoint? To find out more, click here to download a tutorial (PDF format).

    The tool was also recently updated to allow converting repeating data! For more info, click here to download a tutorial (PDF format).

Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.