May 2010 - Posts - Mel Balsamo
in

InfoPath Dev

This Blog

Syndication

Mel Balsamo

May 2010 - Posts

  • How to Use Qdabra’s Encryption XTP

    qRules v2.1 comes with new commands called Encrypt and Decrypt. These allow password-protecting your InfoPath form controls to hide sensitive data. Encryption transforms strings and attachments into a set of random characters, while Decryption reveals the original content after entering the password that’s used to protect the data. Be sure to save your password(s)—Qdabra does not record them.

    To get you started on using qRules encryption in your forms, Qdabra created a template part that you can easily add in your InfoPath Custom Controls and drag over to your forms. It’s called the QdEncryption XTP.

    Quick preview:

    In the screenshot above, the user enters a password and fills out the text field. Clicking on the Encrypt button yields this:

     

    As an added security measure, Qdabra uses a font we called ‘qDots’ to hide the actual texts in the password field. This font comes with the QdEncryption XTP package. To take advantage of it, you should install the font in every machine that will use your form.

    This blog post details the step-by-step instructions on how to use the QdEncryption XTP.

    ADD THE TEMPLATE PART IN INFOPATH CUSTOM CONTROLS

    1. Launch InfoPath and select Design a Form Template based on a new blank one.
    2. In the Controls taskpane, click Add or Remove Custom Controls…

    1. In the Custom Controls dialog box, click Add > Template Part, and browse to the location where you placed your QdEncryption XTP

       

    1. Verify that the XTP has been added to your Custom Controls taskpane.

    1. Save your blank form template (XSN). For the purposes of this tutorial, we will name it as QdEncryptionXSN.
    2. Close InfoPath.
    Inject qRules and the XTP in your Form Template
    1. Launch the qRules Injector from Start > All Programs > Qdabra > Tools > qRules Injector.

    1. Browse to the location where you saved your QdEncryptionXSN.
    2. Click Inject, then OK in the confirmation dialog, and then close the qRules Injector.
    3. Open QdEncryptionXSN in InfoPath Design mode.
    4. Scroll down to the very bottom of the Controls taskpane to get to the Custom section, and then click on the QdEncryption control.

    You should now have the template part on your canvas. The main and the secondary data sources will be injected in your XSN as well.

    Source Files Clean-up

    If you go to Tools > Data Connections, you will notice that you have two instances of QdabraRules, one for the XSN, and one for the XTP:

     

    When you first injected qRules in your XSN, it added the QdabraRules XML as a secondary data source. In this same XSN, you injected the QdEncryption XTP which also uses qRules. This added another QdabraRules XML secondary data source to the XSN (with a different name). So now, you have two qRules XMLs, which is confusing and might cause issues when calling the qRules commands. Unfortunately, there is no workaround at the moment, hence the need to do some clean-up.

    1. Save QdEncryptionXSN as source files and close InfoPath.
    2. Modify the manifest.xsf file:

    a.        In the directory where you saved your source files, locate manifest.xsf and open it in any text editor.

    b.       Replace all 25 instances of "QdabraRules_QdEncryption" with "QdabraRules".

    c.        Delete the associated blocks where you find "QdabraRules1":

                                                                   i.      xsf:file (for .xsd)

     

                                                                  ii.      xsf:file (for .xml)

     

                                                                iii.      xsf:dataObject

     d.     Replace all 12 instances of /xpath=/my:qdEncrypt with /xpath=/my:myFields/my:qdEncrypt

     e.      Replace all 12 instances of /pass=/my:qdEncrypt with /pass=/my:myFields/my:qdEncrypt

    Note that in Steps d and e above, we are replacing the XPaths with /my:myFields. If you have a different name for your main data source group node, please use that instead of myFields.

     f.       Save and close manifest.xsf.

    1. Modify the view.xsl file.

    a.       Open view1.xsl in a text editor.

    b.       Replace the 7 instances of “QdabraRules_QdEncryption” with “QdabraRules”.

    c.        Save and close view1.xsl.

    1. Modify the sampledata.xml file

    a.        Open sampledata.xml in a text editor.

    b.       Delete the xd:DataConnection block where you find “QdabraRules_QdEncryption”.

    c.        Save and close sampledata.xml.

    1. Delete the extraneous QdabraRules1 files in the source files directory:

    a.       QdabraRules1.xml

    b.       QdabraRules1.xsd

    1. Verify changes.

    a.       Open manifest.xsf in InfoPath Design mode.

    b.       Go to Tools > Data Connections and verify that you now have only one instance of QdabraRules.

    Test Your Form Template

    Test the encryption in Preview mode:

    1.       Enter a password.

    2.       Fill out any of the fields you wish to encrypt.

    3.       Click on the Encrypt button corresponding to the field you’ve filled out.

    A ‘Success’ message is shown upon successful encryption.

    If you’ve encrypted a text field, the control will be hidden. The texts will be replaced with random characters starting with “qdEncrypted”, like shown:

    An expression box is displayed instead:

    4.       Enter the password that you used to encrypt and click Decrypt. This will reveal the original texts.

     If you’ve encrypted an image or a file attachment, the attachment will be hidden. An expression box is displayed instead. Decrypting reveals the attachment.

    5.       You may also test encrypting/decrypting the fields all at once by entering a password and filling out all the fields.

    Clicking on the Encrypt All button will show:

    To decrypt, enter the password that you used to encrypt, and click Decrypt All.

    6.       Also try entering a wrong password when decrypting. This will return an error message.

    Additional Notes

    Below are some guidelines that will help you, should you wish to customize the template part or wish to create your own InfoPath forms using the qRules Encrypt and Decrypt commands:

    · Arguments:

    o    /xpath: XPath to the field to encrypt/decrypt

    o    /dsnamepass – (optional) Data Source name for Password field if it is in a secondary data source

    o    /pass: XPath to the password field

    o    /clear: (optional) can have a value of yes or no. If set to yes, the password will be

          cleared after encryption/decryption. If unspecified, the value defaults to yes. 

    · Examples:

    o    Encrypt /xpath= /my:myFields/my:textEncrypt /pass=/my:myFields/my:password

    o    Encrypt /xpath=/my:myFields/my:imageEncrypt  /pass=/my:myFields/my:password /clear=no

    o    Decrypt /xpath=/my:myFields/my:fileEncrypt   /dsnamepass=myEncryption /pass=/myEncryption/Password

    o    Decrypt /xpath=/my:myFields/my:group1/my:group2/my:field1[../my:field2='a'] /pass=/my:myFields/my:password

    · Additional Observations:

    o    Encrypting/Decrypting file or image attachments will make the control appear empty in the form because it can’t read the filename and extension from the string any longer. However the encrypted string will always start with “qdEncrypted”. Conditional formatting can be based off that to hide a control if the node starts with qdE, and display an expression box instead.

    o    Fields that use whole number or decimal as data types can be encrypted/decrypted; but since we are returning a string, the field will return a data validation error.

    o    You cannot encrypt/decrypt a secondary data source field because every time we pull data into a form from a secondary data source, it would be the actual data. Encrypting it would only be until the data was refreshed, since it isn’t stored with the form.

  • Working with a qRules solution that uses DBXL and MOSS 2007

    With DBXL, you can quickly integrate your solution with SharePoint 2007 and IPFS in order to create a browser-based solution. However, the challenge is that InfoPath Forms Server can only open documents from SharePoint document libraries. Connecting an existing form template with DBXL for use on IPFS can be done by using code to access the DBXL web services; but now that there’s qRules, all this can be done without the need of writing code.

    NOTE: For a browser enabled, InfoPath 2010 form template, injected with qRules v2.4 and used on SharePoint 2010 and DBXL v2.4, please refer to this document.

    Since browser forms allow users to pass in custom parameters via the URL, we will pass in the DBXL document ID (DocID) using the qRules command called GetInputParameter. If passed in, we use a data connection to DBXL to retrieve the document then replace the main DOM with the retrieved XML using the new qRules command called SwapDomWithDocument.

    This document details the steps on how to configure your qRules-based solution that can submit documents to DBXL and load them in IPFS. This requires qRules v2.1 (or later) and DBXL v2.3 (or later). For creating SharePoint data views, SharePoint Designer is required.

    The document outlines the following:

    ·        Create the data connections

    ·        Configure the qRules commands

    ·        Configure the submit command

    ·        IPFS-enable your form template

    ·        Publish your form as an admin-approved form template

    ·        Create an IPFS-enabled SharePoint library

    ·        Create a document type in DBXL

    ·        Test the solution

    ·        Create a data view to access your DBXL forms

    Create the Data Connections

    Our solution will use two web service data adapters, one called GetDocument which will retrieve document data from DBXL, the other called SubmitDocument which will post a modified document back to DBXL.

    1. Design your qRules-injected form template in InfoPath.
    2. Add the GetDocument data connection:

    a.        Go to Tools>Data Connections and click Add.

    b.       Select Create a new connection to: Receive data and click Next.

    c.        Select Web Service in the next screen and Next.

    d.       For the Web Service URL, enter the location of the Qdabra DBXL Document web service. In default DBXL installations, the format would be: http://<YourServerName>/QdabraWebService/DbxlDocumentService.asmx. Click Next.

    e.       Select GetDocument from the list of operations and click Next.

    f.         Double-click on the tns:docId parameter and enter the number ‘0’ (zero), then click Next.

    g.        No value is needed for next tns:docId parameter, so leave it blank and click Next twice.

    h.       Give your data connection a name of your choosing. For this document, we will GetDocument. We will use this name later when we configure our qRules command.

    i.         Uncheck the box ‘Automatically retrieve data when the form is opened’ and click Finish.

    1. Add the SubmitDocument data connection:

    a.        Back in the Data Connections dialog box, click Add.

    b.       Select Create a new connection to: Receive data and click Next.

    c.        Select Web Service in the next screen and click Next.

    d.       For the Web Service URL, enter the location of the Qdabra DBXL Document web service which is the same as what we used in the previous step (http://<YourServerName>/QdabraWebService/DbxlDocumentService.asmx), and click Next.

    e.       Select SubmitDocument from the list of operations and click Next three times, leaving the rest of the defaults.

    f.         Give your data connection a name of your choosing. For this document, we will use SubmitDocument. We will use this name later when we configure our qRules command.

    g.        Uncheck the box ‘Automatically retrieve data when the form is opened’ and click Finish.

    h.       Click Close to exit out of the Data Connections dialog.

    Configure the qRules Commands

    Now that we’ve added our data connections, we need to add rules to the finishedLoading attribute of the QdabraRules (Secondary) data source. This will trigger getting the input parameters on load and use those parameters with the SwapDomWithDocument commmand.
    1. In the Data source taskpane, switch to the QdabraRules (Secondary) data source.
    1. Right-click on the finishedLoading node and select Properties.
    2. In the field properties window, switch to the ‘Rules and Merge’ tab and click Add.

         4.       The first rule will simply stop the succeeding rules to run if the conditions are met. Click on the Set Condition button and add two conditions as shown:

     

         5.       Click OK.

         6.       Check the box ‘Stop processing rules when this rule finishes’. No action is needed for this rule. It should look similar to this: 

    1. Give your rule a name of your choosing and click OK.
    2.  Click Add to add another rule that will call the qRules GetInputParameter command and will use ‘DocID’ as the key.
    3. Click Add Action and leave the first dropdown with the action “Set a field’s value”.
    4. Click on the schema icon next to Field and select the Command node from the QdabraRules (Secondary) data source.
    1. Click OK.
    2. In the Value box, enter the command string: GetInputParameter /key=DocID. (Note that DocID is case-sensitive. It should match the specified parameter in the URL that we will set up in the later part of this document.) Your rule action should be similar to this:

      13.   Click OK twice and then click Add to add the third rule.
    1. The third rule will stop the succeeding rule to run if the specified condition is met. Click on the Set Condition button and add a condition as shown:
     

        15.   Click OK.

        16.   Check the box ‘Stop processing rules when this rule finishes’. Again, no action is needed for this rule. It should look similar to this:

       17.   Click OK, then click Add to add the last rule that will call the qRules SwapDomWithDocument command and will use the resulting ‘DocID’ returned by the GetDocument data connection.
    1. Click Add Action and leave the first dropdown with the action “Set a field’s value”.
    2. For the Field, select the Command node from the QdabraRules (Secondary) data source.
    3. For the Value, click on the fx button and enter the formula:
    concat("SwapDomWithDocument /getdocument=GetDocument /docid=", Result)where the /getdocument parameter is the name of your GetDocument data connection, and /docid is the Result node of the QdabraRules (Secondary) data source. Your formula should look like this:

     

    21.   Click OK three times. We now have four rules in the QdabraRules finishedLoading node:

    22.   Click OK to close the Field Properties window.

    CONfigure the Submit Command

    We will use the qRules command called SubmitToDbxl via rules to enable our forms to submit to DBXL. For this, we will add a button that will trigger the submit rule. (For more detailed, step-by-step instructions, see the tutorial Use qRules to submit to DBXL.

    The SubmitToDbxl qRules command allows specifying three values to use as metadata for each of the forms that are submitted to DBXL.  These values are:

    ·         Name – A title for each form

    ·         Author – The name of the person who created the form, or who last modified it, depending on how you would like to use this value.

    ·         Description – A description for each form

    In order to make these values dynamic, we will use the fields in our form corresponding to each of these metadata values.

    1.       Add three text fields in your form, as shown:

    2.       Drag these fields on your form canvas.

    3.       Next, we will add our submit button. In the Controls taskpane, click on the Button control to add it onto your view.

    4.       Double-click on the button on your canvas to see its properties.

    5.       Label your button ‘Submit’ and give it an ID of your choosing, e.g. btnSubmit.

    6.       Click on Rules, and then Add.

    7.       Give your rule a name of your choosing and click Add Action.

    1. Leave the first dropdown with the action “Set a field’s value”.
    2. For the Field, select the Command node from the QdabraRules (Secondary) data source.
    3. For the Value, click on the fx button and enter the formula:
    concat("SubmitToDbxl /submit=SubmitDocument /doctype=qRulesForms /name=", Name, " /author=", Author, " /desc=", Description)

    where we are concatenating the values in the following parameters:

    ·         /submit – name of the SubmitDocument data connection

    ·         /doctype – specifying a value in this parameter is the same as ‘hardcoding’ the document type name. Since we want to submit forms via IPFS, we will have to declare the doctype in our qRules command. You may give it any name of your choosing, but remember that we will use this when we create our document type in DBXL later. For this document, we will use the name ‘qRulesForms’.

    ·         /name, /author, /desc – the underlines indicate that these are the field that you created above. If you click the Edit Xpath (advanced) checkbox, you should see the full XPaths of the fields.

    Your formula should look like this:

    11.    Click OK to close all the dialogs.

    12.    Our sample form will simply look like shown:

    IPFS-enable your form template

    1.       Go to Tools > Form Options > Compatibility, and enable browser-compatibility:

    2.       Make sure that the Submit button (since it makes use the qRules command) is set to ALWAYS send data to the server. To do this, double-click on the Submit button to show its properties, and go to the Browser forms tab, then select Always.

     
    1. Save your form template to your network or local hard drive. For the purposes of this document, we will name our form template 'qRulesForms'.
    Publish your Form as an Admin-Approved Template

    Since qRules injects code into your forms, you will have to publish your XSN as an admin-approved form template. This allows you to manage the form in one place and use it in many places.

    1. In InfoPath’s menu, go to File > Publish.
    2. Select the option to publish the form template ‘To a SharePoint Server with or without InfoPath Forms Services’ and click Next.
    1. Enter the address of your SharePoint or IPFS site and click Next.
    2. The next page will allow you to publish your form as an Administrator Approved form template. Make sure that option is selected and click Next.
    1. Browse to the local or network location where you wish to save your published form template to, click Save and then click Next.
    2. Add some columns to be promoted to the SharePoint library and click Next, and then click Publish.

    You will see a message that your form was published successfully and you are to give your SharePoint Administrator the information listed on the screen.

    7. Click Close and close InfoPath.You need to be a SharePoint Administrator with access to SharePoint Central Administration to complete the next steps.

    8. Navigate to the Central Administration web site.

    9. Click on the Application Management tab.

    1.  Under InfoPath Forms Services, click Manage form templates.
     
    1.  In the ‘Manage Form Templates’ page, click Upload form template.
    1.  In the ‘Upload Form Template’ page, browse to the location where you saved your published form template and click Save.
    1.  Accept the other defaults and click Upload. You should see a message indicating a successful upload. Click OK.
    2. In the ‘Manage Form Templates’ page, click on the down arrow next to the template that you just uploaded and select Activate to a site collection.

    15. If the Activation Location Site Collection shows an incorrect site, click on the down arrow next to Site collection and select Change Site Collection. (Note: SharePoint almost always defaults to the wrong site collection the first time a form template is activated).

    16.    In the pop-up window, click the Web Application selector menu and choose Change Web Application.

    17.    Click SharePoint - 80, and then click the / to activate to the entire site collection. Click OK twice.

    18.    Close Central Administration.
     Create an IPFS-enabled SharePoint libary

    1.       Navigate to the Site Collection in Internet Explorer.

    2.       Click Site Actions > Create

    3.       Click Document Library or Form Library to create new library.

    4.       Continue to the page to create your new library. Give it a name of your choosing. For the purposes of this document, we will name our library ‘qRulesForms’. Select the options as desired, then click Create.

    5.       Go to the library created and click Settings > Form Library Settings.

    6.       Click Advanced settings under General Settings.

     

    7.       In the Advanced Settings Page, select Yes under Allow management of content types, click Display as a Web page to open forms in the browser, then click OK.

    8.       Back on the Library Settings Page, you should now see a section called Content Types. Choose the link Add from existing site content types.

    9.    Find your administrator-deployed template name in the Available Site Content Types list box and click Add, then click OK.

    10. Back in Settings page, click Change new button order and default content type under Content Type section.

    11. Uncheck the Visible check box for Content Type ‘Form’ or ‘Document’ and click OK.

    Now when users click the New button in the document library, your Administrator-Enable form will launch.

     Create a document type in DBXL

    1.       In DBXL, click on New Configuration.

    2.       In the General tab, Document Type details section, enter the Document Type Name, making sure that it matches the same name that was hardcoded into the form. In this case, we used the name ‘qRulesForms’.

    3.       Click on the file attachment control in the InfoPath Form Template section and attach the admin-approved form template that you have published and saved locally (i.e. not the one in SharePoint).

    4.       Click Save, and then OK in the confirmation dialog.

     Test the Solution

    1.       Test creating and updating a new document from the browser.

    a.        In the DBXL Administration Tool (DAT), click the Documents tab and observe that there are no documents listed.

    b.       In your IPFS library, click on the down arrow next to New and select the admin-approved form template that you have published.

    c.         The form will open in the browser. Fill out the fields and click on the Submit button. (Do not close the form.)

    d.       In DAT, click Refresh and verify that the submitted document appears.

    e.       Back in the form in IPFS, modify the description and click Submit.

    f.         In DAT, click Refresh and verify that the document is now showing the modified value in the Description column. Notice that the DocID column has not changed because the form is now connected to the previously submitted document.

    2.       Test opening and updating an existing document from the browser.

    a.        To open an existing document, specify the DocID parameter in the URL.

    You can identify a document ID by looking in DAT under the DocID column. The URL to open this document would then look like: http://<YourServerName>/_layouts/formserver.aspx?XsnLocation=/FormServerTemplates/<FormTemplatePublished>.xsn&OpenIn=Browser&DocID=<DocumentID>.

    b.        In a new web browser window, navigate to this URL, replacing <YourServerName> with yours, changing <FormTemplatePublished> with the name of your admin-approved template which in this case is ‘qRulesForms’, and setting the <DocumentID> parameter to the one for your document. In this case, the document we have submitted in Step 1 has a DocID of 253. Your URL should then look like: http://mySharePointSite/_layouts/formserver.aspx?XsnLocation=/FormServerTemplates/qRulesForms.xsn&OpenIn=Browser&DocID=253.

    c.        Verify that your form opens in the browser without errors.

    d.       Modify the description and click Submit.

    e.       In DAT, click Refresh and verify that the document shows the changed value in the Description column.

    3.       Test submitting documents via DBXL and opening them in the browser.

    a.        In DAT, go to the General tab and click on the Download icon  to open the form in InfoPath.

    b.       Fill out the form fields and click Submit.

    c.        Go to the Documents tab and verify that the submitted document appears.

    d.       Open the document in the browser by passing in the DocID parameter in the URL. Use the same URL as before, replacing DocID with that of the newly-submitted document.

    e.       Verify that your form opens in the browser without errors.

    f.         Continue submitting new documents to have at least 3 in preparation for the next task.

    Create a data view to access your DBXL forms

    To make the process of opening and submitting documents easier, it will be best to add a data view to the SharePoint site that would list all the documents in DBXL via the GetListItems method. This requires the installation of SharePoint Designer.
    1. In the SharePoint Designer menu, go to File > Open Site.
    2. Enter the URL for your SharePoint site and click Open.
    3. In the ‘Folder List’ pane, navigate to the SharePoint library that you created in the previous steps, which in this case is ‘qRulesForms’.
    4. Expand qRulesForms > Forms, and double-click on AllItems.aspx to open it in the designer.
    5. In the menu, go to Data View > Manage Data Sources.

    6.       Under XML Web Services, click Connect to a web service.

    7.       Enter the Service Description Location (URL) to the DBXLDocumentService, usually located at http://<servername>/QdabraWebService/DbxlDocumentService.asmx, and click Connect.

     

    8.       In the Operation dropdown, select GetListItems.

    You should be able to see the following:

    9.       Select listName and click Modify, then enter the name of the Document Type you wish to query. Remember that we have already created a document type and have named it ‘qRulesForms’.

    10.    Click OK.

    11.    Go to the General tab and enter a name for the connection.

    12.    Go to the Login tab and select Use Windows authentication, then click OK.

    13.    The new web service connection will show up under XML Web Services in the Data Source Library. Click the down arrow for the connection you just created and click on Show Data.

    The Data Source Details tab will show the columns retrieved from the Document Type. For the purposes of this document, we will do the following:

    14.    Hold down the Ctrl key and use your mouse to click on the DocID, Name, Author and Description.

    15.    Drag and drop these columns onto a location on the page where you wish to display this data. Your canvas should now look like this:

    16.    Add a hyperlink to open the documents in the browser:

    a.        Click on  next to any entry in the column you wish to display form links in. A menu will appear:

    b.       Select Hyperlink in the ‘Format as’ dropdown. Click Yes when prompted.

    c.        In the ‘Edit Hyperlink’ dialog, click on the Parameters button.

    d.       Remove the text in the Path field and enter http://<YourServerName>/_layouts/FormServer.aspx, replacing <YourServerName> with yours.

      1. Click on the Add button to start adding your query string parameters:

    i.         In the Name field, enter XsnLocation.

    ii.        In the Value field, enter the relative path to the published form template, e.g. /FormServerTemplates/qRulesForms.xsn, then click OK. 

    Continue to add the following parameters:

    iii.      DefaultItemOpen = 1 

     

    iv.      DocID = {@DocID} (Select XSL: DocID from the Value dropdown and remove the @ sign in the Name)

     

    v.        OpenIn = Browser

     

    vi.      Source = (relative path where the user is taken when they close the document), e.g. /qRulesForms/Forms/AllItems.aspx.

     
    You should now have the following Query strings: 

     

    f.         Click OK.

    g.        In the ‘Edit Hyperlink’ dialog, enter {@Name} as the text to display.

     

    h.        Verify that the link generated in the Address field is correct. The address should be in the format: http://<YourServerName>/_layouts/formserver.aspx?XsnLocation=/FormServerTemplates/<FormTemplatePublished>.xsn&DefaultItemOpen=1&DocID={@DocID}&OpenIn=Browser&Source=/<YourSharePointLibary>/Forms/AllItems.aspx

    i.         Click OK to close the Edit Hyperlink dialog.

    17.    In the menu, click File > Save to save the changes to your SharePoint library.

    18.    In Internet Explorer, navigate to your SharePoint library. You will now see your new data view added onto your SharePoint library.

    Test opening new forms in the browser by clicking on the New link, and submitting using the Submit button. Your form will be submitted to DBXL and get displayed on your SharePoint data view. Test opening existing forms and verify that they open in the browser, and that you can modify and submit any changes.

     

    Posted May 29 2010, 06:28 AM by jose cruz with 1 comment(s)
    Filed under: , ,
  • How to use the SetValue command

    InfoPath allows us to set the value of a target field by using rules. We can even filter which field we want to set the value of. However, it can be a problem if that field happens to be in a repeating group.

    The qRules SetValue command allows us to define the XPath to the target field. Using XPath filters with the SetValue command, setting a field’s value can be extremely easy when dealing with repeating data.

    ·         Arguments:

    o    xpath: XPath to the field to set

    o    value: New value for the field being set

    ·         Examples:

    o    SetValue /xpath=/my:myFields/my:Group/my:RepeatingGroup/my:field2[../my:field1='abc'] /value=ABC

    o    concat("SetValue /xpath=my:myFields/my:Group/my:RepeatingGroup/my:field2[../my:field1='", Filter, "'] /value=", Value)

    This document assumes that you already have a qRules-injected form template. To demonstrate how the above examples work, design your form template based on the following guidelines/steps:

    1.       Your main data source structure should be similar to this (all use a string data type):

    2.       You have the following layout and controls on your canvas:

    3.       In your ‘Set Value’ button properties, click on Rules.

    4.       Add a rule that has an action that sets the value of your QdabraRules (Secondary) data source Command node:

    to: SetValue /xpath=/my:myFields/my:Group/my:RepeatingGroup/my:field2[../my:field1='a'] /value=Test

     

    5.       Preview your form template.

    6.       Insert at least 5 items in your repeating table.

    7.       In the Field 1 column, fill out some fields with the text ‘a’, and others with random texts, like shown:

    8.       Click on the ‘Set Value’ button. You should get the result as shown:

     

    In this example, we set our qRules Command to:

    SetValue /xpath=/my:myFields/my:Group/my:RepeatingGroup/my:field2[../my:field1='a'] /value=Test

    Using this command syntax, qRules will set the value of any row in the Field 2 column that has ‘a’ in Field 1. It sets the value of Field 2 to ‘Test’.

    Like the other qRules command, you can also use a ‘concat’ statement if you wish to use specific fields with dynamic values in your parameters. For the next example, we’ll use the command syntax:

    concat("SetValue /xpath=my:myFields/my:Group/my:RepeatingGroup/my:field2[../my:field1='", Filter, "'] /value=", Value)

    9.       Back on your canvas in Design mode, change your button rule to set the value of the qRules Command node to the concat statement above. Note that since ‘concat’ is an InfoPath function, you will have to enter it as a formula, pointing Filter and Value to their respective nodes in the main data source:

    10.    Preview your form template.

    11.    Enter ‘John’ in the Filter text box and ‘John Smith’ in the Value text box.

    12.    Insert at least 5 items in your repeating table, filling out some fields with the text ‘John’, and others with random texts, like shown:

    13.    Click on the ‘Set Value’ button. You should get the result as shown:

    When you’ve started using the SetValue command in your InfoPath solutions, you’ll see how helpful it is and how it can make dealing with repeating data easier.

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