December 2010 - Posts - Mel Balsamo
in

InfoPath Dev

This Blog

Syndication

Mel Balsamo

December 2010 - Posts

  • New! qRules v2.4 Form Flags Sample Form

     The qRules Form Flags sample form features the following qRules Commands:

    • IsNew - checks if form is new and sets the form version to '0'. This form version increments as changes are made to the form.
    • IsDirty - checks if the form has changed. If there are no changes and user clicks Save/Submit, the form will not save/submit to the server.
    • SetDirty - resets the IsDirty flag to 'false' on successful submit to allow further changes the next time the form is opened.
    • IsReadOnly - checks if the form is currently opened by another user and prevents save/submit if so.
    • ClearErrors - clears validation errors to allow users to save the form regardless if the required fields have been completed or not.
    • GetErrorCount - counts the number of validation errors in the form; if present, users will not be allowed to submit.
    • SetCaption - sets the form title to the form's name in the SharePoint library.
    • SetSave - prevents File > Save to the SharePoint library.
    • Bonus:
      • Checks if a newer version exists on the server.
      • Detects the form status (Saved/Submitted), version and DocID which are all displayed on the form's footer.
    Click here to download the sample form.
  • Free Training: Using InfoPath Workflow

    You may be familiar with SharePoint workflow, but have you added workflow to an InfoPath template? InfoPath workflow is easier to use because it's handled in InfoPath instead of requiring the user to complete certain actions in SharePoint.

    Users can easily see the state of the form and you can add custom conditional viewing to switch views based on the user role (e.g. a private Comments section in a Manager's view).

    During this lab, you will modify a Timesheet form template to pull user information from Active Directory, submit to SharePoint, and pass the SharePoint link in the notification email.

    Retrieving the Users' Active Directory Information

    If you go to Data > Data Connections, you'll see the pre-configured data connections that use Qdabra DBXL's Active Directory Web Service methods to retrieve the users' information.

    And if you go to Data > Form Load, you will see a rule that populates the user info:

    We're basically setting the fields in our form to the values retrieved from the Active Directory web service methods and using filters to specify which Key to use.

    Add the Submit Data Connections

    Start by modifying the starter template to add data connections that submit the form to SharePoint and through email.

    1.       Open the Starter Template XSN (included in this lab) in InfoPath Designer.

    2.       Save the template on your local machine by going to File > Save As and saving it with the name Timesheet.xsn

    3.       Add the data connection to submit to your SharePoint library.

    a.    Go to Data > Data Connections > Add > Create a new connection to submit data > To a document library on a SharePoint site

    b.    Enter the name of your document library, such as http://training.qdabra.com/personal/<<username>>/

    c.    For the File Name, click on the fx button and insert the formula:

    concat(tc:week/tc:weekOf, " - ", tc:employee/tc:name/tc:singleName)

    If you click on the Verify Formula button, you should see the following:

    d.    Click OK in the Insert Formula dialog.

    e.    Check the box ‘Allow overwrite if the file exists'.

    f.    Click Next, leave the default data connection name, and then click Finish.

    4.       Add an email submit data connection.

    a.    In the Data Connections dialog, click Add > Create a new connection to submit data > As an email message

    b.    Click on the fx button next to the To field and select the emailto field which you'll find under the my:actions group in the main data source.

    c.    Click on the fx button next to the Subject field and enter the formula:

    concat("Time Card: ", tc:week/tc:weekOf, " - ", tc:employee/tc:name/tc:singleName, " has been ", my:actions/my:status, " by ", my:actions/my:modifiedby, ".")

    If you click on the Verify Formula button, you should see the following:

    d.    Click OK in the Insert Formula dialog and then click Next.

    e.    Make sure that the option ‘Send only the active view of the form and no attachment' is selected.

    f.    Click Next, leave the default data connection name, and then click Finish.

    5.       Click Close to exit out of the Data Connections wizard.

    Add the Rules that Trigger the workFlow

    In the Employee (default) view, you'll see a Submit button. This button will have rules that will set the form fields' values that are being used in the workflow, such as who modified the form, whom is it assigned to after the form submits, which email address should it be sent to, etc. Same goes for the Approve and the Reject buttons which you'll find in the Manager view - they have rules that trigger the workflow.

    Since the form also has a Form History section for tracking purposes, you may find other rules that set the history data. These have already been added in the form so we can concentrate on implementing the logic that is associated with the workflow.

    Start by modifying the Submit button:

    6.       In the Employee view, click on the Submit button.

    7.       From the Home tab > Rules section, click Manage Rules to display the Rules taskpane.

    You will see the following pre-configured rules:

    8.       Add a rule that sets the metadata

    a.    In the Rules taskpane, click New > Action.

    b.    Name your rule ‘Set Metadata'.

    c.    Move the rule up so that it's the third in the set, i.e. after the rule ‘Warn: Need Hours'.

    d.    Set the modifiedby field:

    i.    Click Add > Set a field's value.

    ii.    For the field, select modifiedby under the my:actions group:

    iii.    For the value, click on the fx button and select singlename under employee > name

    You can also just enter the following XPath in the Insert Formula dialog: tc:employee/tc:name/tc:singleName

    iv.    Click OK to close the dialogs.

    e.    Set the assignedto field:

    i.    Click Add > Set a field's value.

    ii.    For the field, select assignedto under the my:actions group.

    iii.    For the value, click on the fx button and select singlename under employee > name.

    iv.    Click OK to close the dialogs.

    f.    Set the emailto field:

    i.    Click Add > Set a field's value.

    ii.    For the field, select emailto under the my:actions group.

    iii.    For the value, click on the fx button and select emailAddressPrimary under company > contact. You can also just enter the following XPath in the Insert Formula dialog: tc:company/tc:contact/tc:emailAddressPrimary

    iv.    Click OK to close the dialogs.

    g.    Set the status field:

    i.    Click Add > Set a field's value.

    ii.    For the field, select status under the my:actions group.

    iii.    For the value, enter the text Submitted

    iv.    Click OK.

    h.    Set the notes field:

    i.    Click Add > Set a field's value.

    ii.    For the field, select notes under the my:actions group.

    iii.    For the value, enter the text Submitted to Manager

    iv.    Click OK.

    You should now have the following Submit button rules that set the metadata:

    9.       Add a rule that submits the form:

    a.    Click New > Action.

    b.    Name your rule ‘Submit' - this will be the last rule in the set.

    c.    Submit to SharePoint:

    i.    Click Add > Submit data.

    ii.    Select your SharePoint Library submit data connection from the drop-down:

    iii.    Click OK.

    d.    Set the done field:

    i.    Click Add > Set a field's value.

    ii.    For the field, select done under the my:actions group.

    iii.    For the value, enter 1

    iv.    Click OK.

    Notice the conditional formatting in the Submit button:

    This means that we want the Submit button to be disabled if the value of the done field equals "1" which we set after the form submits to SharePoint. This will prevent users from clicking on the Submit button twice which may result to double-submits.

    e.    Submit via email:

    i.    Click Add > Submit data.

    ii.    Select your email submit data connection from the drop-down.

    iii.    Click OK.

    f.    Close the form:

    i.    Click Add > Close the form.

    ii.    Uncheck the box ‘If changes have not been saved, prompt the user to save.

    iii.    Click OK.

    You should now have the following Submit button rules that submit the form:

    Next, we will add rules in the Approve button:

    10.    Go to the Page Design tab and switch to the Manager view.

    11.    In the Manager view, click on the Approve button. You will see the following pre-configured rules:

    12.    Add a rule that sets the metadata.

    a.    In the Rules taskpane, click New > Action.

    b.    Name your rule ‘Set Metadata'.

    c.    Move the rule up so that it's the second in the set, i.e. after the rule ‘Warn: Need Notes'.

    d.    Add the following actions:

    13.    Add a rule that submits the form:

    a.    Click New > Action.

    b.    Name your rule ‘Submit' - this will be the last rule in the set.

    c.    Add the following actions:

    Finally, we'll add rules for the Reject button:

    14.    In the Manager view, click on the Reject button.

    15.    Add the same ‘Set Metadata' rule that runs after the ‘Warn:Need Notes' rule.

    16.    Add the following actions:

    17.    Add a Submit rule which is the last in the set, and then add the following actions:

    18. Save your changes to your XSN.

    Create the Form Link

    We will add a hyperlink control that links to the form in SharePoint. The link will be included in the notification email so that users can click on it to open the form.

    19.    In the Manager view, you'll see a small section at the bottom. Place your cursor below the label ‘Click here to open this time card:'

    20.    Go to the Insert tab and click Hyperlink.

    21.    In the Insert Hyperlink dialog, change the Link to and the Display options to Data Source.

    22.    Insert the formula:

    concat(substring-before(substring-after(/processing-instruction()[local-name() = "mso-infoPathSolution"], 'href="'), "/Forms/"), "/", tc:week/tc:weekOf, " - ", tc:employee/tc:name/tc:singleName, ".xml")

    The formula is a concatenation of the form location in SharePoint, e.g. http://<YourSharePointSite>/<YourSharePointLibrary>/<FormFileName.xml>

    Recall that we've set the form file name to this formula on SharePoint submit:

    Publish the Template to your SharePoint Library

    In order to access the form template and submit forms, you need to publish it to a location where users can access it from, such as a SharePoint form library.

    23.    Go to File > Publish and then select SharePoint Server.

    24.    Enter the URL to your SharePoint site.

    25.    Leave the default to Form Library and then click Next.

    26.    Select ‘Update existing form library' and select the SharePoint library you created earlier - that is, where you've set your forms to submit to.

    27.    Click click Next twice, click Publish, and then click Close.

    Test by submitting a new Timesheet form assigning it to your manager. Your manager will receive the form via email and will see a link where to access the form.

    The manager will then open the form via the link and will decide whether to approve or reject. Approving goes to HR and rejecting goes back to the original submitter.

  • Free Training: Data-Driven Design - Using XML Files to Configure Other Forms (Lab 2)

    In this lab, your business process has evolved and you have many more questions and answers. You decide using a configuration form is more efficient so you'll modify your Quiz Form from Lab 1. In real life, you could also create a form that pulls from a configuration form without going through the steps in Lab 1.

    Create a Form out of your Template

    1.       Open your Quiz Form template in InfoPath Designer.

    To make sure you are not overwriting your template for Lab 1, change the title and save it with a different name.

    2.       Preview your form template, go to File > Save As and save it as Config.xml. This will save the schema as well as the default data in an XML format.

    3.       Close Preview.

    Add a Data Connection to the XML File

    We are going to add our new configuration XML as a resource to our template.

    4.       Go to the Data tab > Data Connections, and then click Add.

    5.       Add a data connection that receives data from an XML document.

    6.       Browse to the Config.xml file saved earlier.

    7.       Click Next twice leaving the default selections, click Finish and then click Close.

    Change the Drop-Down to get Choices from the Secondary Data Source

    8.       Modify the data source for the SelectedModule drop-down list box to use the default Modules in the new Config data source:

    a.   Right-click on the SelectedModule drop-down and select Drop-Down List Box Properties.

    b.   Change List box choices to Get choices from an external data source. The Data source will default to the Config data connection you created earlier:

    c.   Click on the icon next to Entries, select the Module repeating group under Modules and then click OK.

    d.   Leave Value set to my:ModuleNo, but change Display name to my:ModuleName, and then click OK.

    Use InfoPath Functions to Get Row Numbers

    In this section, we will use the built-in InfoPath functions count and preceding-sibling to create row counts for the Module and the Question repeating groups. We will use these row counts as default values to the ModuleNo and the QuestionNo fields. We will then use a formula to auto-increment the fields as we add new rows to the repeating groups.

    9.       Set the default value of the ModuleNo field.

    a.   In the Fields taskpane, double-click on the ModuleNo field to display its properties.

    b.   Under Default Value, click on the fx button next to the Value box.

    c.   Enter the formula: count(../preceding-sibling::my:Module) + 1

    d.   Click Verify Formula and you'll see this:

    e.   Click OK twice.

    10.    Set the default value of the QuestionNo field.

    a.   In the Fields taskpane, double-click on the QuestionNo field to display its properties.

    b.   Under Default Value, click on the fx button next to the Value box.

    c.   Enter the formula: count(../preceding-sibling::my:Question) + 1

    Change the Default Values to Pull Data from the Secondary Data Source

    In the Fields taskpane, if you double-click on the ModuleName field of the main data source to see its properties, you will see the the default value you've manually added from Lab 1. We will change this value to pull from the configuration file instead.

    11.    Click on the fx button and then click Insert Field or Group...

    12.    Switch to the Config (Secondary) data source and follow the series of steps shown in the image below to select and filter the ModuleName field.

    13.    Click OK four times.

    If you check the Edit XPath (advanced) box, you'll see the XPath xdXDocument:GetDOM("Config")/my:QuizForm/my:Modules/my:Module/my:ModuleName[../my:ModuleNo = current()/../my:ModuleNo]

    This means that the control will show the value of the Config ModuleName field  filtered so that the Config ModuleNo is the same as the main ModuleNo which is being set by the incrementing Module row count we've set earlier. Everything inside the square braces ( [ ] ) is an XPath filter. Basically, we are telling InfoPath we'd like the ModuleName from the Config and then providing further information to make sure the correct module name is selected.

    14.    Click OK twice to close the dialogs.

    Next, we will change the question texts' default values to pull from the configuration file using the same technique.

    15.    Double-click on the QuestionText field of the main data source to see its properties, you will see the the default value you've manually added from Lab 1.

    16.    Click on the fx button and change it to point to the secondary data source:

    a.   Click Insert Field or Group...

    b.   Switch to the Config (Secondary) data source and select QuestionText.

    c.   Click Filter Data... > Add.

    d.   Select QuestionNo in the first drop-down.

    e.   Choose Select a field or group... in the third drop-down.

    f.   Switch to the Main data source and select QuestionNo.

    g.   Click OK once.

    17.    We will add another filter condition in order to get only the question set for the corresponding module.

    a.   Back in the Specify Filter Conditions dialog, click on the button labeled And.

    b.   Choose Select a field or group... in the first drop-down.

    c.   Select the ModuleNo field from the Config data source and click OK.

    d.   Choose Select a field or group... in the third drop-down.

    e.   Switch to the Main data source and select ModuleNo.

    f.   Click OK four times and then check the Edit XPath (advanced) box to see the formula

    The formula used is: xdXDocument:GetDOM("Config")/my:QuizForm/my:Modules/my:Module/my:Question/my:QuestionText[../my:QuestionNo = current()/../my:QuestionNo and ../../my:ModuleNo = current()/../../my:ModuleNo]

    Here again, we are telling InfoPath we'd like the QuestionText from the Config and then added filters to make sure the correct question for the corresponding module is selected.

    Add More Default Rows

    At this point, you would want to add a couple more default rows for your repeating groups so that you'll have placeholders for new items that are added via the Config.xml.

    18.    Go to the Data tab > Default Values.

    19.     Expand Modules >  Module (last repeating group), and then select the last Question repeating node.

    20.    Click on the down-arrow key next to node, and then select Add another Question below.

    21.    Keep adding until you have about 10 repeating Question nodes. Note that if you ever exceed this, i.e. you modify Config.xml to add more than 10 questions for a module - you will need to do this step again and add placeholders.

    22.    When done, select the last Module repeating node and also add more until you have about 5.

    23.    Click OK when done.

    When you preview your form template, you will see almost no difference to the template you've created for Lab 1 - only now, we are not using default data; instead, our data is retrieved from a secondary XML data source.
  • Free Training: Data-Driven Design - Using Default Data (Lab 1)

    In this lab, you will be provided with a starter form template that has a simple pre-designed layout, the schema, and an email submit data connection so that you won't have to create them from a blank template.

    Take time to familiarize yourself with the form schema by looking at the fields in the main data source as well as how the controls are laid out on the design canvas.

    Add Default Values to the List of Modules

    Notice the Module dropdown - this lists all the modules with default values which we will configure in this lab. If you right-click on the SelectedModule dropdown list box (under the heading Select a Module) and select to show its properties, you will see that it gets choices from the Module repeating group - from within the main data source.

    In order to provide options for this dropdown, we need to add default values for the ModuleNo and ModuleName fields.

    1.       Go to the Data tab > Default Values.

    2.       Expand Modules > Module (first repeating group), select ModuleNo and then enter the default value: 1.

    3.       Select ModuleName and then enter the default value: Module 1 - Getting Started.

    4.       For the second Module repeating group, add the following default values:

    • ModuleNo: 2
    • ModuleName: Module 2 - Schemas

    You may also add default nodes manually. For this lab, we will add a third Module.

    5.       Click on the down-arrow key next to the second Module repeating node, and then select Add another Module below.

    This will add another set of Module and Questions with the last-entered values copied over by default.

    6.       Replace the default values with the following:

    • ModuleNo: 3
    • ModuleName: Module 3 - SharePoint Integration

    7.       Click OK when done.

    When you preview your form template, you should see the Module dropdown list box populate with the default values you've added:

    Add Default Values to the List of Questions

    We will also ‘hardcode' values for the QuestionNo and the QuestionText fields, hence giving them their default values.

    8.       Close Preview and then go back to the Data tab > Default Values.

    9.       Expand Modules > Module > Question.

    10.    Each module will have a list of three questions. Add the following default values for the QuestionNo and the QuestionText for each corresponding module (to save time, copy from this document and paste into the Default Value box of the respective field).

    ModuleName
    QuestionNo
    QuestionText
    Module 1
    1
    Guidance text helps users fill out forms. List three ways to add guidance text to your form.

    2
    InfoPath Designer starts with the main data source. When building a form from the ground up (blank), why is it important to identify your secondary data sources up front?

    3
    How do you uniquely name an email when you submit the form?
    Module 2 1
    What are the pros/cons of using an XML resource in the XSN vs. XML from a network share?

    2
    How do you change the default value for choice group?

    3
    How do you change default value for choice group?
    Module 3 1
    What's the difference between Save and Submit?

    2
    Why does Microsoft promote SharePoint workflows? Why are the benefits?

    3
    List 3 things that browser-based forms can't do. Why not?

    Let's also add two more default Question nodes for Module 3; but this time, there will be no default values for the questions, i.e. blank - we will conditionally hide blank questions later.

    11.    Click on the down-arrow key next to the last Question repeating node, and then select Add another Question below twice.

    12.    Delete the copied-over values in the QuestionNo and QuestionText fields for both nodes.

    13.    Click OK when done.

    Conditionally Hide Questions

    If you preview your form template at this point, you will see all the default questions you've just added. We don't actually want to show them all. Instead, we'd want to display only those questions corresponding to the selected module.

    14.    In the Fields taskpane, select the Module repeating node.

    15.    From the Home tab > Rules section, click Manage Rules to display the Rules taskpane.

    16.    Add a conditional formatting that hides questions that don't belong to the selected module.

    a.   Click New > Formatting.

    b.   Name your condition something like "Only show questions for the selected module".

    c.   Click ‘None' under Condition to display the dialog where you can add your conditions

    d.   In the Condition dialog, leave the first dropdown pointing to the ModuleNo field but change the comparison (second dropdown) to ‘is not equal to'.

    e.   On the third dropdown, choose Select a field or group..., choose the SelectedModule field of the Main data source.

    f.   Click OK twice and then check the box ‘Hide this control'.

    Your conditional formatting should look similar to this:

    We also need to conditionally hide questions that have no default values, i.e. those that are blank.

    17.       In the Fields taskpane, select the Question repeating node.

    18.       Add your conditional formatting:

    a.   In the Rules taskpane, click New > Formatting.

    b.   Name your condition something like "Hide blank questions".

    c.   Click ‘None' under Condition to display the dialog where you can add your conditions

    d.   In the Condition dialog, leave the first dropdown pointing to the QuestionNo field but change the second dropdown to ‘is blank'.

    e.   Click on the button labeled And and then change the operator to or.

    f.   Select QuestionText in the first dropdown and then change the second dropdown to ‘is blank'.

    g.   Click OK and then check the box ‘Hide this control'.

    Your conditional formatting should look similar to this:

    Once again, preview your form template. After you select a module, you should be able to see the default questions for that module. If you select Module 3 - SharePoint Integration, you should still see only 3 sets of questions - others that have blank values are hidden.

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