Ernesto Machado
in

InfoPath Dev

Ernesto Machado

  • Using qRules on a machine with both Infopath 2007 and 2010 installed

    When trying to use qRules in InfoPath 2007, you might run into the following error IF you also have InfoPath 2010 installed on the same machine:

    An unexpected error occurred executing the rule. Action: SortTable
    Arguments:
    row: my:myFields/my:Items
    compare: my:Group
    order: ASC
    type: text

    Details: It is an error to mix objects from different versions of MSXML.

    Stack:   at Microsoft.MsoOffice.InfoPath.MsxmlInterop.MsxmlDocument.ThrowExceptionFromMsxmlInteropError(MsxmlInteropError eError)
       at Microsoft.MsoOffice.InfoPath.MsxmlInterop.MsxmlDocument.ThrowExceptionFromHresult(Int32 hrError)
       at Microsoft.MsoOffice.InfoPath.MsxmlInterop.MsxmlNodeImpl.AppendChild(String strXml)
       at Microsoft.Office.InfoPath.MsxmlWriter.Close()
       at System.Xml.XmlWellFormedWriter.Close()
       at System.Xml.XPath.XPathNavigator.AppendChild(XmlReader newChild)
       at System.Xml.XPath.XPathNavigator.AppendChild(XPathNavigator newChild)
       at Qdabra.Tools.RulesLibrary.Commands.SortTable(String domName, String rowXPath, String fieldXPathList, String orderList, String typeList)
       at Qdabra.Tools.RulesLibrary.Commands.SortTable()
       at Qdabra.Tools.RulesLibrary.Commands.ExecuteCommand()

    The issue is with MSXML interop between 2007 and 2010, which happens when a machine has InfoPath 2010 installed as well. The solution is to use InfoPath 2010 since there is no known workaround for the MSXML difference between 2007 and 2010. When you use InfoPath 2010, this error should not come up.

  • InfoPath 2010 fails to update DAT due to caching issue

    If you are using Database Accelerator (DBXL) v2.4 with InfoPath 2010, you might encounter an issue when opening the DBXL Administration tool (DAT).

     

    If you click Show Details, you'll get: "Forms that require the domain permission level contain features that access information on a network".

    This appears to be a caching issue in InfoPath 2010, due to the fact that InfoPath 2010 doesn’t automatically attempt to get an update for the form. This only happens if you had a previous version of DBXL installed.

    The workaround is relatively simple:

    1.    Close all InfoPath instances, and verify that the InfoPath process is not running.

    a.    Right click on the task bar and select Start Task Manager.
    b.    Click on the Processes tabs and click on the Image name header to sort the processes.
    c.    Look for InfoPath.exe.
    d.    If it exists, select it and click End Process.



    2.    Open InfoPath.

    3.    In the File tab select New. You will see the DBXL Admin Tool listed under Qdabra Tools.

    Note: If you don’t see DAT in the list of available forms, open Internet Explorer and go to the DBXL page: http://<servername>/qdabrawebservice, and then click on the DBXL Administration Tool link. The error dialog might still appear; close it. When you re-open InfoPath, you should now see DAT in the list.

    4.    Right-click on the form and select ‘Get update of this form’.

     

    5.    Close InfoPath filler.

    6.    Try to launch DAT again.

    DAT will update and InfoPath should no longer display errors whenever you click on the link in the DBXL page or open from your available InfoPath forms.

  • Documentation for Qdabra's Database Accelerator v2.4

    Qdabra Database Accelerator (DBXL) helps you quickly connect InfoPath forms to your SQL database and improve SharePoint submit and query performance. DBXL was first released in 2004 and supports many mission critical applications today. Qdabra recently released DBXL v2.4; for more information, please visit the product page on Qdabra.com.

    Below is a list of available documentation for DBXL v2.4.


  • How to use the FormatDate and GetWeekDay commands

    Introduction

    qRules v2.1 includes two new commands that allow you to work with the date fields in your InfoPath form.

    GetWeekDay allows you to specify a date and a weekday, and the command will return the date value for the specified day of the week. This would allow us, for example, to obtain the Monday relative to the start of the current week. FormatDate, on the other hand, will allow us to change the format of a date value.

    This tutorial will walk you through an example where the two commands are used together. First we will generate a list of Mondays to select from. After we have a list of Mondays, we will reformat the date values into a more user-friendly format.

    Pre-requisiteS

    This tutorial assumes that you have qRules v2.1 already 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.1 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.

    Generate a list of Mondays to select from
    1. We first need to add the fields we will need for this tutorial.
      1. Switch to the Data Source taskpane, right click and select Add.

      1. Design the data source seen below, where all of the fields are of data type date, except for Display, which should be a string.

    1. Next we will create on load rules to generate values to these fields.

    3.       Go to Tools > Form Options. Under Open and Save > Open behavior, click Rules.

    4.       Click Add. Name your rule Setup Monday Dropdown.

    5.       Click Add Action and select Set a field’s value from the Action dropdown.

    6.       For the Field, select the Command node from the QdabraRules secondary data source.

    7.       For the Value, we will use the GetWeekDay command to retrieve the Monday relative to today’s date. When the command does not contain the /date parameter, the command will use today’s date. The command is: GetWeekDay /day=Monday

    Now that the qRules command has executed, its result is stored in the Result node in the QdabraRules secondary data source. We must store this value in another field before we execute another command, since the result of any other command will overwrite the Result node.

    8.       Click Add Action and select Set a field’s value from the Action dropdown.

    9.       The Field will be the SeedDate and the Value will be the Result, as shown below.

    Next we will generate a list of Mondays based on this SeedDate. We can use the qRules command SetValue to add values to our repeating group.

    10.    Click Add Action and select Set a field’s value from the Action dropdown.

    11.    For the Field, select the Command node from the QdabraRules secondary data source.

    12.    For the Value, click on the fx button, click on Insert Function, and select the concat function. Prepare the concat statement as seen below.

    concat("SetValue /xpath=/my:myFields/my:Dates/my:Day[1]/my:Value /value=", xdDate:AddDays(my:Dates/my:SeedDate, 21))

    What does this command mean? SetValue allows us to set the value of the given xpath, in this case, the first node in the repeating my:Day/my:Value. The value is another function, which adds 21 days to our SeedDate. This means we will be generating a Monday date three weeks into the future.

    Before adding more dates, we need to add more rows into the repeating group. To do this:

    13.    Click Add Action and select Set a field’s value from the Action dropdown.

    14.    For the Field, select the Command node from the QdabraRules secondary data source.

    15.    For the Value, enter Insert /parent=/my:myFields/my:Dates /child=my:Day /count=6. The /count parameter is set to six because we will be adding six more date values.

    Now you have six new, blank rows in the repeating my:Day group. Populate them with dates by repeating steps 10, 11 and 12, and simply changing the index on my:Day and the number of days added to the SeedDate. The commands will look like this:

    concat("SetValue /xpath=/my:myFields/my:Dates/my:Day[2]/my:Value /value=", xdDate:AddDays(my:Dates/my:SeedDate, 14))concat("SetValue /xpath=/my:myFields/my:Dates/my:Day[3]/my:Value /value=", xdDate:AddDays(my:Dates/my:SeedDate, 7))concat("SetValue /xpath=/my:myFields/my:Dates/my:Day[4]/my:Value /value=", my:Dates/my:SeedDate)concat("SetValue /xpath=/my:myFields/my:Dates/my:Day[5]/my:Value /value=", xdDate:AddDays(my:Dates/my:SeedDate, -7))concat("SetValue /xpath=/my:myFields/my:Dates/my:Day[6]/my:Value /value=", xdDate:AddDays(my:Dates/my:SeedDate, -14))concat("SetValue /xpath=/my:myFields/my:Dates/my:Day[7]/my:Value /value=", xdDate:AddDays(my:Dates/my:SeedDate, -21))

    As a result, now the my:Day repeating group has a my:Value field populated with the current week’s Monday date, as well as the Monday dates from three weeks into the future and three weeks into the past.

    Use FormatDate to set the Display to a user-friendly Format

    Despite our progress, the my:Display field is still not set. Fortunately, we can use FormatDate to do this and provide a user-friendly date format.

    16.    To your data source, add a dropdown field and display it in the form’s view.

    17.    Set the dropdown to Look up values in the form’s data source, with the Entries, Value and Display settings set as shown below.

    18.    Right-click on the my:Value node and select Properties.

    19.    Switch to the Rules and Merge tab and click Add.

    20.    Click on Set condition. Select Value in the first dropdown and select is not blank from the middle dropdown.

    21.    Click on Add Action.

    22.    For the Field, select the Command node from the QdabraRules secondary data source.

    23.    For the Value, click on the fx button, click on Insert Function, and select the concat function. Build the function like this, where the dot (.) represents the current field (my:Value).

    concat ("FormatDate /date=",.," /format=d")

    24.    Click Add Action and select Set a field’s value from the Action dropdown.

    25.    The Field will be the my:Display node and the Value will be the Result from the QdabraRules secondary data source.

    What do these steps accomplish? Every time that an entry is added to the my:Value field in the previous section, this new rule will format the date into a user friendly value and store it in the my:Display field.

    26.    Preview the form to verify the values shown by the dropdown.

    Options for FormatDate

    How do we know how to format the date? The format is controlled by the /format parameter. In the example above, we used the parameter ‘d’, but what does that mean? To find out, visit MSDN: http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx. There are numerous options for using FormatDate with custom formats and the MSDN link above explains these options.

    To illustrate the power of FormatDate, we will change the command in step 23 to concat("FormatDate /date=", ., " /format=dd MMMM yyyy") and Preview the form to see the new date format in the dropdown.

    You can even use something like /format="Arriving at " hh:mm to get "Arriving at: 09:03", as shown below.

    In the examples above we show the usage of dd MMMM yyyy and hh:mm to create customized date/time formats. However, you can also use an escape character, like this: %h. This is what MSDN tells us:

    To use any of the custom date and time format specifiers as the only specifier in a format string (that is, to use the "d", "f", "F", "g", "h", "H", "K", "m", "M", "s", "t", "y", "z", ":", or "/" custom format specifier by itself), include a space before or after the specifier, or include a percent ("%") format specifier before the single custom date and time specifier.

    To summarize: while this command allows the developer to create any number of different date formats, it also opens the door for formatting issues. As you design your form, you’ll want to debug your command carefully to make sure you obtain the desired result.

     

  • A space in the URL, encoded as %20, causes issues for QuerySharePoint

    When using QueryBuilder and QuerySharePoint, you need to enter the URL to your SharePoint list. Internet Explorer encodes spaces as %20, but DBXL produces an error if you use a URL containing a %20.

    The workaround is simply to replace %20 in the URL with an actual space. This works in QueryBuilder and in the InfoPath data connection wizard.

  • DBXL Sharepoint Mapping: When Object Model should work but doesn’t

    When creating a Sharepoint mapping from the DBXL Administration Tool (DAT) you have two options: Object Model and Web Service. Web Service is required when the Sharepoint instance lies on a different server. However, we have seen instances where Object Model produces an error, even though DBXL and Sharepoint are on the same machine.

    How do you know if you’re in this situation?

    1. Add a Sharepoint mapping. Select Web service. Save the document type. Add documents and verify that everything works as expected.
    2. Edit the same doctype to use Object Model. When you click Save in DAT you get this:

     

    Simply using Web Service is an acceptable workaround for some people. But if you wish to use IPFS (browser enabled forms) you’ll need to use Object Model. So how do we fix this?

    When faced with this scenario please check the Applications eventlog. It is our experience that we find a SharePoint error with Network Service not having permission to access the Sharepoint database.  Evidently, the object model does direct database access. To fix this, switch DBXL to use the same identity as the SharePoint app pool.

  • QuerySharepoint cannot derive a schema with blank fields

    The QuerySharepoint web service allows you to retrieve data from a SharePoint list. It requires a <query> parameter, which can be built using the QueryBuilder form that comes with DBXL. QueryBuilder allows you to specify the columns you wish to retrieve.

     

    In the screenshot above, you can see that I wish to retrieve three columns. I generate my query and proceed to create the data connections in my form. In InfoPath, I go to Tools > Data connections and create a receive-type connection. For the <query> parameter, I enter:

    <query maxrows='2'><columns><column name='Category'/><column name='Unit_x0020_of_x0020_Measure'/><column name='ProductCode'/></columns></query>

    Notice that the data source taskpane will show me the xml structure that was returned by this new data connection:


    Where are my other two columns?! This issue was recently encountered by one of the users of DBXL (read it here).

    If we look at the source SharePoint list, we’ll notice that the first two items in my list contain blank values in those columns.

     

    Because of these blank values, the web service was unable to derive the correct schema.

    The workaround is simple: increase the value of the maxrows parameter. Then the data connection “sees” that third row, and returns the columns correctly:


    That’s a bit tedious, especially if you have a large list with many blank values. So the workaround becomes even simpler: remove the maxrows parameter!

  • Repeating fields: Copy individual nodes using qRules

    Using qRules you can use the commands CopyTable and MoveTable to copy or move an entire table.

    But what about copying individual repeating fields? We can do this by using Insert and a couple of InfoPath tricks. The steps below illustrate a simple example from which you can extrapolate others.

    First we need to design our form.

    1.    Create a new, blank InfoPath form and inject it with qRules v1.7.

    2.    Create a data source as seen in the screenshot below.

     

    3.    Go to Tools > Data Connections and create a new data connection that retrieves data from an xml file every time the form is opened. Here is a screenshot of my xml file.

     

    Your secondary data source will look like this:

     

    4.    Right-click on the repeating node called name and select Repeating table to insert it into the view.

     

    5.    Next to each the text field, insert a button. Double-click on it and change its Label to “Copy over”.

    6.    Right-click on the repeating node in the main data source and select Repeating table to insert it into the view.

    By now, your view looks like this:

     

    We don’t want the destination table to have any rows when the form loads.

    7.    Click on Tools > Default Values, uncheck the repeating field in the main data source, and click OK.

     

    Now we need to configure our rules.

    8.    Double-click on the button and click Rules.

    9.    Click Add, then click Add Action.

    10.    Select Set a field’s value from the Actions dropdown.

    11.    Click on the icon next to Field and select the Command node in the QdabraRules secondary data connection.

    12.    For Value, enter the command we will execute: Insert /parent=/my:myFields /child=/my:field1 /count=1. Click OK.

    13.    Click Add Action.

    14.    Select Set a field’s value from the Actions dropdown.

    15.    Click on the icon next to Field and select the repeating field in your main data source.

    16.    Click on the icon next to Value, click on Insert field or group and select the repeating node in the secondary data connection.

    17.    Click OK to close all dialogs.

    Finally, we need to manually modify the xpath of the destination to make sure we are only copying into the node we just inserted.

    18.    In InfoPath, click File > Save As Source Files and choose a destination folder in your local drive.

    19.    Navigate to that folder and open manifest.xsf in a text editor.

    20.    Locate the node <xsf:ruleSets> towards the end of the file. This node contains your form’s rules.

    21.    Find the second rule we created. In the case of our sample form, it looks like this <xsf:assignmentAction targetField="xdXDocument:get-DOM()/my:myFields/my:group1/my:group2/my:field1" expression="."></xsf:assignmentAction>

    22.    Change the rule to add [last()], as seen here: <xsf:assignmentAction targetField="xdXDocument:get-DOM()/my:myFields/my:group1/my:group2/my:field1[last()]" expression="."></xsf:assignmentAction>

    Resave the form and test:

    23.    Save manifest.xsf.

    24.    Right-click on the manifest and select Design.

    Double-click on the button and then click Rules to verify your rules. This is what your rules will look like once you are done:

     

    Optionally, select the second action and click Modify. Verify that the xpath to the target field is underlined; this visual cue indicates that InfoPath has recognized our manual modification.

    Now you can preview the form and test it! Click on copy over for John Doe and that value gets inserted into the destination table.

     

    Click on copy over for Bruce Wayne and that value gets inserted into the destination table.

     

    Posted Aug 04 2009, 09:01 AM by ErnestoM with no comments
    Filed under:
  • Conditional SQL mapping with DBXL v2.3

    This blog entry assumes you have completed tasks 1, 2, 3 and 5 in the DBXL v2.3 Getting Started document. In other words, I assume that you have already:

    1. Configured an InfoPath form to submit to the DBXL web service.
    2. Created a document type in DBXL using that form.
    3. Added SQL mapping.
    4. Successfully submitted documents and verified their shredding.

    Though we can always add validation in the InfoPath form to prevent users from submitting with blank fields, we can also prevent DBXL from shredding certain documents. We call this conditional mapping.

    For example, the Expense Report sample that ships with InfoPath 2007 (and is used in the Getting Started document) does not require the user to enter a Purpose. Suppose we don’t want to map documents that have a blank Purpose. In this case, we don’t want the second row in our database, because of the blank Purpose field.

     

    So we must resort to conditional SQL mapping. For this particular example, this means “let’s only send this data to SQL when a certain field is not NULL”.

    Only one small change needs to be made in the mapping. Where we previously had this:

    And now we change to:

    We manually added a condition in the note path for the table: /my:expenseReport[my:purpose != ""]. We empty our SQL table and click the Reshred All button in DAT, and we obtain the following data shredded into SQL:

     

    So we have successfully filtered on the xpath, excluding (from SQL) rows where the Purpose field is blank.

  • qRules v1.7 sample form

    After installing qRules v1.7 you can get a quick glimpse into some of the commands. Simply navigate to the installation folder (usually C:\Program Files\Qdabra Software\Qdabra Rules Library) and locate the qRulesForm.xsn. Right-click on that form template and select Design.

    You'll find that the form contains multiple views to illustrate the usage of the following commands:

    • CopyTable
    • MoveTable
    • DateDiff
    • Delete
    • IsDirty
    • SetDirty
    • ExecuteAction
    • GenerateGuid
    • GetErrorCount
    • Insert
    • Replace
    • SortTable

    Click Preview and test out the commands!

    If you want to see how the commands are configured, you can switch to the appropriate view in InfoPath's design mode and check the rules implemented in each button. Along with the qRules v1.7 User Guide, this will allow you to get these commands up and running in your own forms in no time!

    Posted Jul 29 2009, 10:00 AM by ErnestoM with no comments
    Filed under:
  • DBXL v2.3: Trying to promote a field called "Description"?

    DBXL v2.3 allows you to map your DBXL xml documents into a SharePoint form library. You can use the "Publish Library and XSN" checkbox to create a new form library or update an existing one.

    However, if you promote a field as “Description”, the SharePoint form library will not display the column, even though it seems configured properly in both SharePoint and InfoPath. No errors are displayed in the Event Viewer. This is an issue that we will continue to investigate going forward and address for DBXL v2.4.

    As a workaround, when you promote that field, name it something other than “Description”.

  • Save as PDF in InfoPath (and Office 2007)

    Microsoft has an exporter that allows you to save InfoPath (and Office 2007) documents as PDF files. You can download the add-in here. There is an additional add-in that allows you to save as either PDF or XPS. Click here for that.

    But Microsoft also has detailed instructions on how to save as PDF in each of the Office 2007 programs. Click here to read these step-by-step instructions.

  • Querying manager information using Active Directory

    Qdabra’s Active Directory Web Service allows you to obtain the manager’s alias for a given username. This means that you can load the information for the currently logged in user, then determine his or her manager, then query again to obtain the manager’s full information.

    One common issue we have encountered is the difficulty to determine the sequence and triggers for the rules that call the Active Directory web service to accomplish the goal above. A previous blog entry gave you a glimpse into the sequence of necessary steps, but used a button to query the manager’s information due to a limitation around template parts. If you don’t want a button on your form, and want all the information to load when the form opens, the steps are quite similar.

    The blog post explains three data connections that are necessary.

    • GetMyInfo
    • GetManagerAlias
    • GetUserInfo

    When setting those up, make sure to check “Automatically retrieve data when the form is opened” for GetMyInfo, and uncheck it for the other two.

    There are three general steps that need to execute:

    1. Query GetMyInfo to obtain the Active Directory information for the user that is opening the form.
      • As a result of this query you will obtain the user's alias, which you need as the input for the query in step 2.
    2. Query GetManagerAlias to retrieve the manager for the current user.
      • As a result, you’ll obtain ONLY the manager’s alias, which you’ll need as the input for the query in step 3.
    3. Query GetUserInfo to obtain the Active Directory information for the manager.

    However, don't use rules on a specific field. [For example, DON'T create a rule that executes when the user’s name is retrieved from Active Directory (field is not blank).]Instead, go to Tools > Form Options > Open and Save > Rules and add them there. The rules will then execute when the form opens.

    Once you’ve executed these three rules, you can use the Active Directory information as you please. You can populate fields for both the user and the manager (e.g. name and email), as shown in this document or in this previous blog entry. To try the Active Directory web service, you can download a free copy of Database Accelerator, or obtain our standalone tool by checking out the Products page on Qdabra.com.

  • "Save As" in the DBXL Administration Tool (DAT)

    If you edit an existing Document Type in DBXL you’ll see a button labeled Save As in the header. This is an easy way to create a duplicate of your configuration, but under a different name.

    Why is this useful? Here are two possible scenarios:

    • Database mapping: Because this action copies the Database mappings, this is useful if you wish to avoid recreating a large mapping to SQL. This also allows you to create the same mapping but to a new database or SQL instance, by replacing the Connection String.
    • Development and Testing: Save As allows you to create a test DocType. You can edit the InfoPath form, create test documents, edit the SharePoint or Database mappings, or alter Permissions. Once you have tested, you can edit your original DocType to apply whatever changes you wish to implement. This way, you avoided altering your main Document Type (which might be in use by users in a Production environment). 

    These are but two scenarios where the Save As button might prove useful.

  • When only the first row of a repeating table is committed to SQL database

    While setting up a child table database mapping in DAT (whether in DBXL v2.2 or DBXL v2.3), you might find that only the first row of the repeating table (mapped to the child table) is committed to the child table.

    The reason for the problem is an error in mapping. Since it is a very subtle mistake, I wanted to briefly explain via this blog post. The explanation below assumes you have read this document.

    This is the data source for the form:

    As you can see, we have a repeating group (Contact) inside the group called Contacts.

    The parent table is easily mapped, using the fields OwnerName, OwnerPhone and OwnerEmail. The mistake when creating a mapping for the child table is when the user maps the child table to Contacts instead of Contact. When that is done, the columns are mapped as shown below.


    Incorrect

    The solution is to change the child table mapping to Contact, and then remap the fields, to obtain the mapping shown below.


    Correct

    The reason for this is simple: the repeating group is Contact and not Contacts. Fix your mapping and you’ll be able to map all of the rows of your child table.

More Posts Next page »
Copyright © 2003-2010 Qdabra Software. All rights reserved.
View our Terms of Use.