March 2017 - Posts - Mel Balsamo
in

InfoPath Dev

This Blog

Syndication

Mel Balsamo

March 2017 - Posts

  • Query Forms from within other Forms

    You may download the files used in this blog post from this link

    Overview

    Sometimes you have a form and you want to show another form's data, without actually copying it into your form.

    In other words, you don't want to include the queried form into your form. You just want to link the forms together and show the related form as a reference.

    How do you add this "satellite" form to your main form without impacting the design of your main form?

    In this blog, we'll show you how to query and display data from a separate satellite form without ruining the integrity of your main form.

    Requirements

    • You are a site collection admin.

    • Your site has the FormsViewer App installed, or your SharePoint admin can install it.

    • You have an InfoPath form or access to InfoPath Designer to create one.

    Sample Scenario = Policies

    Every business process needs a policy. The policy may change throughout the year. For example, an expense report may require receipts for expenses exceeding $100 this year, but this limit may be raised to $150 next year. The business process admin should be able to update the policies by going in to the Policy library and adding/updating forms.

    Usage Scenario

    View Policy

    1.       User opens up your form

    2.       Clicks on Show Policy

    3.       If no matching policy exists, Main form shows "No policy document"

    4.       If policy form exists, Main form queries the policies form

    5.       Main form displays the policy

    Add or Edit Policy

    1.       Business Process Admin adds a new policy with the name for the main form which it will target

    Components

    To implement, you will need the following:

    • Policies Form - required

    • Policies XTP - generic XTP that can be configured

    • Your Main Form - where you insert the XTP

    Technique

    Query the Policy form library using the URL for the Main form (as if it is a unique ID to search for a policy).

    Here’s how the Policy Form looks like – simple and straightforward.

    image1 

    Publish your Policy form into your SharePoint library. Submit your business process policies using that form, specifying the Target Form Name, e.g. Expense Report, Leave Request, etc. and entering your Policy text in the rich text field which allows formatting, paragraph breaks, etc.

    Here’s an example of a filled-out Policy form:

    image2 

    There’s also the Policy XTP (template part) that allows easily adding policies into your forms. Here’s how it looks like in the Designer:

    image3 

    Add the XTP into your InfoPath Designer Custom Controls:

    image4 

    We will add the Policy XTP into the Expense Report form that ships with InfoPath 2007.

    image5 

    Follow the steps provided in the XTP – we made it very simple and user-friendly for you! J

    Key notes:

    • Make sure to enter the same form name you specified when you submitted the Policy Form. Recall that we submitted policy and gave it a Target Form Name of “Expense Report”

    image6

    The same name should be specified as the default value in the Policy XTP section’s TargetFormName field:

    image7 

    • In the PolicyLibraryUrl field, enter the URL to the library where you published the Policy Form to. Make sure to include the trailing slash, like so:

    image8

    • The XTP appended the “_Policy” text in the data connection names so you’ll need to rename the data connection for QdabraRules (only) so that FormsViewer recognizes the commands.

    image9

    Those are all the changes needed – super easy! J

    How the Magic Happens

    All the rules are placed in the Show Policy button:

    image10 

    We use the following commands/technique:

    • ChangeConnectionUrl – to change the URL of the BusinessProcess_Policy XML data connection

    image11

    We are basically telling our form to get the policy text from the Policy Form library to the form where we added the XTP to, in this case, the Expense Report form.

    • CopyRichText – if a policy has been submitted for our form, we then copy the value from that Policy form into our Expense Report form.

    image12

    Since we’re copying to and from a rich text field, we use the command CopyRichText in order to keep any rich text formatting.

    That’s all there is to it! When you’re done setting it up, publish your form into FormsViewer and test out your changes.

    image13 

    image14 

    Have fun! J 

  • Create a Child Form from within a Parent

    (Click here to download the files used in this blog post.) 

    Overview

    When you're designing a form, you don't need to include "everything but the kitchen sink”. I confess abusing this idiom in the past. It means "almost anything one can imagine". I have used "kitchen sink" as a metaphor for an InfoPath form from hell that has everything thrown into it. Visually, I imagine a kitchen sink so full that it is impossible to wash the dishes.

    It's easy for a form to become bloated and unwieldy.

    For example, imagine that you have a simple Expense Report form that submits to a SharePoint library. Good job! You publish and people start using it and they are happy for a month or so. Then, you get a feature request to add a simple approve-request workflow. So, you add a "Change History" section to your form (we have an XTP for this) and promote properties for the last modified user and date-time fields to integrate with a new SharePoint workflow. This makes sense because you can now measure the time between submit and approval or rejection and resubmit, etc. You can't do that with SharePoint workflows, so it makes sense to add this repeating block to your form. Fine. Another month goes by and somebody wants you to add a Expense Policy to the form. Now, you know that there are many business policies in your org and during a slow Tuesday afternoon you daydream of creating a general form for policies and linking them together but then when Wednesday rolls around, you're slammed with other work and you just don't have time to do that so you hard-code the policy into the form and that gets the job done, but you know you'll have to republish with every update. Let's hope the policy doesn’t change often.  After another month and yet more feature requests and suggestions, you finally put your hand to your head and in a flash of insight realize that whack-a-mole is the wrong game for you. Instead, you will design a place in your form where users can submit suggestions.  You will automate the task of improving your form and in the process get control of your work week back. You will schedule one time every two weeks to review form feedback and schedule changes. Life will be orderly.  Only one problem: how to extract suggestions saved in the Expense Report form…

    Here's where it makes sense to have two dishwashers. You've got one for glass stemware and another for pots and pans. Different cycles for different dirtiness. Your Expense Report form and Suggestions will be in different libraries. The Expense Reports need to be processed quickly. The suggestions, not so much. OK, that's the idea, but how to extract the latter suggestion from the former expense report and yet still give people a "ticket #" so that they feel like their suggestion didn't end up in the black hole of SharePoint?

    With Qdabra's easy-to-inject Suggestions XTP, you can add a Suggestions section to your form and have it saved to a separate library.

    Requirements

    • You are a site collection admin.
    • Your site has the FormsViewer App installed, or your SharePoint admin can install it.
    • You have an InfoPath form or access to InfoPath Designer to create one.

    Sample Scenario = Add a Suggestion Box to your form

    Adding a Suggestion Box to your form is a great way to capture feedback, and defuse negativity of a new process. If someone calls to say there's a bug, you can have them enter it into the suggestion box right away and promise them some turnaround.  They're happy you listened.

    qRules has a command called SubmitToSharePoint which users to create a different XML document and submit to a SharePoint form library. It supports “create” and “update” actions for XML fragments based on an XML mapping.

    How it Works

    This lab provides a Suggestion form and a Suggestion template part (XTP). If you open both in InfoPath Designer and compare the Suggestion form’s main schema against the XTP’s Suggestion secondary data source schema side-by-side, you’ll see that the XTP contains the schema of the Suggestion form.

    Suggestion Form:

    Suggestion XTP:

    When you add the Suggestion XTP into your form, the XTP will add the schema as an XML to the secondary data source.

    Design the Form that Submits Suggestions

    For your convenience, we are providing a sample form template that you can start with. You will continue designing this form as if it’s one of your company’s solutions.

    1. In InfoPath Designer, open the template named xsn.
    2. Add your fields and controls – you can add any field you want; but for the purpose of this exercise, we’ll add fields for Suggestion, Project, Submitter, and FormName; and use text box controls on the canvas.

    1. Publish the form to a Library.
      1. Click File Publish SharePoint Server.
      2. Enter the training site URL (https://training2013.formsboard.com/MastersCourse/). Click Next.
      3. Select Form Library and click Next.
      4. Select Create a new form library and click Next.
      5. Enter a unique name for your form library. For example, <YourName>_Part12_Lab1.
      6. Click Next twice and Publish.
    2. Add your Submit and Close buttons

    1. Create a Submit to Library data connection
      1. Under the Data tab, click Data Connections.
      2. Add a Submit data connection that submits To a Document Library on a SharePoint site.
      3. Enter the URL for the library created in step 3.
      4. For the File name, click the fx button and select the FormName
      5. Click Next until you reach the last page of the data connection wizard.
      6. Leave the SharePoint Library Submit name as is, and click Finish to exit the data connection wizard.
    2. Double click the Submitter field, click the fx button, and enter the formula userName().
    3. Click on the Submit button.
    4. Under the Home tab, click Manage Rules.
    5. Add an action rule named Generate FormName.
    6. Click the Condition
    7. For the first dropdown, select the FormName
    8. Select “is blank” from the second dropdown.

    1. Add an action that sets the FormName field

    1. Click the fx button and enter the formula: translate(concat(Project, "-", Submitter, "-", now()), ' ~#%&*{}<>:,?\/|"+.…', "_____________________")
    2. Highlight Project and click the button Insert Field or Group
    3. Select the corresponding Project field and perform the same step for the Submitter
    4. Click OK
    5. Add another action rule that Submits Data using the SharePoint Library Submit data connection, and name the rule accordingly.
    6. Save the form and click the quick publish icon  located at the upper left section of your screen to perform a quick republish.
    7. Perform a test submit to verify the submit works – the XML generated will be used for identifying the Processing Instructions of the XML.
    8. Download the generated XML and save it on your desktop or downloads folder. 

    Add the Suggestion XTP

    You will then add the Suggestion XTP that will allow suggestions to be submitted into the target Library we created earlier.

    In this section, you may use any form you wish to use but for purposes of training, a QdExpenseReport-Sample pre-injected with qRules form has been provided.

    Note that qRules is required. You may need to inject your form with qRules if you are using a different form.

    1. Add the XTP in InfoPath Custom Controls.

    1. Drag the Suggestion XTP on your form canvas.

    This is how the XTP looks like on the design canvas:

    In your Fields task pane, notice that the XTP added groups and fields into your main data source.

    If you go to Data > Data Connections, you will see that the XTP also added data connections:

    And if you select the Submit Suggestion button then display the Rules task pane via Home > Manage Rules, you’ll see the pre-configured rules:

    These are just some of the benefits of using XML Template parts (XTPs) – it adds almost everything for you; in short, you let the XTP do the hard work. Another huge plus is that you can use XTPs in as many forms as you want.

    Modify the XTP

    We will make a few modifications to the Suggestion section so that it meets our form’s needs.

    1. Move the light bulb icon (drag-and-drop) where you want it to appear on your form.

    1. Add data connection that submits to the Suggestion Form library.
      1. Under the Data tab, click Data Connections.
      2. Add a Submit data connection that submits To a Document Library on a SharePoint site.
      3. Enter the URL for the Suggestion Form library.
      4. For the File name, click the fx button and select the node /ns1:SuggestionForm/ns1:FormName from the Suggestion_ Suggestion secondary data connection.
      5. Click Next until you reach the last page of the data connection wizard.
      6. Provide a meaningful name such as SubmitSuggestion, and click Finish to exit the data connection wizard.
    2. Click Submit Suggestion button
      1. Modify Action rule named Insert PIs - set target field to qRules Command node for both actions.
      2. Modify Action rule named Submit to Suggestion Library - set target field to qRules Command node
    3. At the Xtp_Logic_Suggestion secondary data connection, click the node /XtpLogic/Action/SetXMLValues
      1. Modify Action rule name Set Library Name* - set Value to the Library name of the Suggestion Form (not the Expense report form)
      2. Modify Action rule name Set URN* - set Value to the URN of the Suggestion Form
        1. Open Suggestion Form in deign mode
        2. Go to File > Info > Form template Properties
        3. Copy the URN from the ID section
        4. Exit form
    4. Back at the Submit Suggestion
      1. Click the first rule named Set Values.
        1. Modify the value of the action that sets the Project field to a value you desire – this should correspond to the current form you are adding the submit suggestion xtp to.

      2. Modify the second rule named Insert PIs.
        1. Open the XML saved in step 21 using a text editor such as notepad.
        2. On the first action, update the corresponding values for the following Processing Instruction attributes:
          • solutionVersion
          • productVersion
          • PIVersion

        3. On the second action, verify if the values for the /data parameter are the same. If not, update the attribute values accordingly
          • InsertPi /dsname=Suggestion_Suggestion /name=mso-application /update=true /data=progid="InfoPath.Document" versionProgid="InfoPath.Document.3"
        4. Double check the /dssubmit parameter value – make sure that the value is the same as the Submit to Library data connection name create in step 25 g. By default this should be: SubmitSuggestion
    5. Save your final template.

    See it In Action!

    Now that we have set it all up, we are ready to test our solution.

    1. Publish your form template to SharePoint by creating a new Library (see step 5 for reference).
    2. After Publishing the form, Open a  new document.
    3. Submit a suggestion.
      1. Click on the light bulb icon where you placed it.
      2. The Suggestion box should appear – fill in the fields.
      3. Click on the Submit Suggestion

    1. You should see a link to the submitted suggestion.

    1. Click on the link to open the Suggestion form that you just submitted.

     

  • Send a Form Link via Workflow

    Overview

    How about approving workflow requests via email with one click?

    With Qdabra's easy-to-install FormsViewer app, you can do this and more.

    Wouldn't it make even more sense to approve workflows from a phone without having to login to SharePoint?

    Well, now with FormsViewer, even external users can approve requests. One click. No log in required.

    Faster, better, easier - that's FormsViewer!

    Important: please don't attempt this while driving.

    Requirements

    You are a site collection admin.

    Your site has the FormsViewer App installed, or your SharePoint admin can install it.

    You have an InfoPath form or access to InfoPath Designer to create one.

    Sample Scenario = Leave Requests

    A Leave Request form is a common scenario where approvals are required.

    Steps 

    Employee requests personal time off (PTO)

    1. Employee navigates to HR site

    2. Employee clicks on Submit Leave Request

    3. Employee fills out form and submits

    Manager is notified

    1. Manager receives an email summarizing the PTO request

    2. Manager clicks on link to approve or reject request

    Components

    To implement, you will need the following:

    • One Leave Request form (InfoPath)

    • One Manage Leave Request form (InfoPath)

    • One SharePoint 2010/2013 workflow

    Note: You can download and install our Leave Request solution from the Qdabra web store here:
    http://www.qdabra.com/webstore/p/1152/leave-requests-form

     

    Technique

    To approve or reject a request with one click, you need to tell the form whether you are "approving" or "rejecting" when you click. So, there are two links. One link has "&Approval=Approved" and the other has "&Approval=Rejected".

    To create these links and send an email we will use SharePoint Designer…

    Here's the workflow:

    image1

    Here's the email:

    image2

    Here's the link for "Approved":

    image3

    image4

    To create a link for rejecting, you just change the "&Approval=Approved" to "&Approval=Rejected".

    Now, let's take a look at the form.

    Qdabra's Leave Requests solution has a form for submitting requests (Leave Requests form) and a form for managing the leave requests. Both are included in the package.

    The workflow that sends emails with the approve-reject links is associated with the former Leave Requests form.

    But, the links themselves point to the latter Manage Leave Requests form.

    The Manage Leave Requests form opens when the manager clicks the link and there is logic after form load that sets the approval status based on the command that was passed.

    Here's how the form canvas looks like in InfoPath Designer:

    image5a 

    Here are the rules that get the approval status:

    image5b 

    Notice that we are using the qRules command "GetInputParameter" to query the link for the Approval key. This key indicates whether the manager has "approved" or "rejected" the request.

    After obtaining the approval status, we next need to get the ID of the form:

    image6

    Once again, we are using the qRules GetInputParameter command to query the form's ID from the link.

    After getting the link, we can query the form:

    image7

    Notice that the rule queries the form from the Leave Requests library - that is where it was submitted.

    Next, the form updates the library based on the approval.

    image8

    That's all there is to it.

    Just create a workflow link that appends the form's ID and the Approval command. Then, in the form use qRules GetInputParameter to query these values from the link and perform some actions based on what they are.

    To do this even if the user is not logged in, just add one more parameter:

    image9

    Of course, you'll want to look at the samples. :)

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