How to use the GetAttachmentAttribute command - Aruna Akella
in

InfoPath Dev

Aruna Akella

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.

               

Comments

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