Tag : infopath

InfoPath has a limit on the file size when publishing forms to a document library. In some cases the combined size of the files embedded into the form can exceed this limit. To work-around this issue, consider creating an additional document library that allows the user to add documents with a link to the form. Then, in your form create a Data Connection to this table to show the attachments and allow the user to click on the hyperlink to the attachment. If you are feeling adventurous, add another link that connects directly to the SharePoint List in Add Mode, and pre-populates the key fields in the attachment List item using an Info-Path Web Part (See the link InfoPath – Prepopulate a list item from a URL)

In most companies development is ongoing and applications tend to grow horns and tails as users and developers become familiar with existing functionality and require enhancements. This can be a problem especially when working with workflows since although the InfoPath form has changed to the new release, the workflow is still functioning with an older instance. This could mean that functionality in the form is not available in a workflow, since for example, it is only expecting Outcomes 1 through 3, but the form is now providing Outcome 4.

I have found it convenient to develop workflows with the first setting writing the version of the workflow to the SharePoint list (I maintain my own version numbers). That way, when I open the form I will only offer functionality if the workflow version supports it. Alternatively, you can maintain a Form version number and validate against this field

For example, if one only added delete functionality to the system from Version 2.06 onwards, one could create a rule that hid the control so that the user could not select it as shown below

In most of my forms that are linked to workflows, I provide the ability for an administrator to restart the workflow at a particular point if needed. This is not only useful in testing situations (since a workflow can skip time consuming steps if they have already been completed), but it provides much needed flexibility in SharePoint where server throttling situations can result in a suspended workflow which needs to be restarted at a previous point.

In this case I maintain a ‘StartFrom’ combo box in my ‘hidden’ view, that if changed sets a value ‘Restart’ to true. If I need to restart a particular workflow at a specific point, I do the following:

Terminate the current workflow

Open the form, select the hidden view, and set the ‘StartFrom’ to my starting point

I then restart the workflow. The first stage checks if the workflow is being restarted and then uses a series of linked stages to decide the point at which to restart the workflow

It is often useful in a form to hide certain fields that are only used in rules and calculations, however this can make troubleshooting a form with issues difficult since key data may not be displayed. Displaying these values on the form on the other hand can cause confusion with your users.

In these situations I normally create an alternate ‘hidden’ view that displays all fields, which ‘normal’ users do not see. On one or all of the ‘visible’ views I then add a button hidden to all but me (actually, I usually use another field that has a comma separated list of people who can see the button). When this button is clicked, the alternate view opens up and you can examine all values.

As an added benefit this format allows the people who can access the button to modify any fields if needed. This is very useful in that it can allow you restart workflows at particular points or change some data without having to run a new workflow

When you open many data connections and perform queries through the ‘Form Load’ functionality in InfoPath, it may be that your form takes long to open. To troubleshoot these issues, you can create a local field in InfoPath and write the rule and time to this field each time an action is performed. When the form finally opens, you can query this field to see where the lag is. Example:

Separate your Form Load into multiple rules, grouped by logical function such as ‘Getting Initial User Data’ or ‘Query Attachments’

Add a text field called ‘Log’ and at the very beginning of the first rule, initialize it with something similar to the following:

concat(“Getting Initial User Data:”, string(now()), “,”)

Then, at the beginning of each subsequent rule, and perhaps sometimes within the rule itself, set the field ‘Log’ to a value similar to the following:

concat(Log, @crlf, “Query Attachments:”, string(now()), “,”)

(Note that the field @crlf which formats the field neatly, originates from an XML Data Connection. See ‘InfoPath – Adding special characters such as line feeds’ for more information on how to do this)

Display the ‘Log’ field somewhere on your form (I normally add this to a special view that only administrators have access to – the button to open this view is not displayed if the user is not an administrator

When you view the field, it will have something like the following in it

Data in an Excel sheet is unstructured and often split across multiple tabs. The users I was dealing with were flexible enough to use a couple of cut-and-pastes from Excel into spreadsheet to get this option working. This is what I did to allow the users to import the data:

Setup

Create a separate folder in the Excel spreadsheet for importing the data, called ‘SPImport’.

In row 1, add column headings for each cell that you wish to import. This is so you can easily identify which property is in which cell

In row 2, add a regular Excel expression to point to the cell that contains the data (examples: =Data!A16, =Data!D24 etc.). You can add some additional functions in the row to strip of unneeded characters that could cause a problem in SharePoint loads, including hidden spaces, linefeeds, forward and backward slashes, quotation marks etc.

You will probably need to make a couple of the fields ‘key fields’, meaning that they will contain values that uniquely identify the import

In the end you will have a single row of data that will auto populate with the referenced cells values. This spreadsheet should then become the master spreadsheet for the data

Now, create a SharePoint list, say called ‘SPExcelImport’ that contains the same columns as your spreadsheet and the default Datasheet view in exactly the same format. You may choose to auto populate the Title field or use it to hold one of the values you intend to import.

In your InfoPath form, create a Data Connection to the ‘SPExcelImport’ SharePoint list, provisioning all the fields

In my form I added an ‘Import Button’ that was only enabled when I can find an entry in the ‘SPExcelImport’ list with matching key fields

When the user clicks on the Import button, set the values in the form to the values in the import file (I was dealing with over 100 fields in my example, so I split the Action on the Import button into multiple rules)

Operation

The user completes the spreadsheet

The user opens the ‘SPImport’ folder, highlight the cells in Row 2 that are needed and selects Ctrl-C to copy the data (They should not highlight the entire row as this will attempt to copy all the columns in the row into the spreadsheet and the user will receive an error)

The user opens the ‘SPExcelImport’ table with the cursor on the first cell and presses Ctrl-V to paste the copied values into the SharePoint list. This will paste the cells from the spreadsheet into the SharePoint cells (Sometime, you may find that it copies all the data into a single cell. When this happens, tab out of the cell, shift-tab back in and do the copy again). Stop editing the list

The user then opens the InfoPath form and enters the key data in the header. InfoPath queries the ‘SPExcelImport’ list with the key data and if an entry is available, enables the import button

This applies to lists that are linked to workflows. Since the workflow and InfoPath form are separate processes, it is possible that users can update the form while the workflow is processing data. This ability to update the form gives the user the impression that the updated data is considered and while this is true in some cases, it can be an issue if the workflow is only initiated when items are added to the list, as the workflow may be running based on previous values

To prevent this from occurring, I use a promoted field called ‘Updating’ in the form to test whether the workflow is in the process of updating. When the workflow is updating information, this value is set to ‘true’. When the user opens the form during this stage, the forms checks this value and if it is set to ‘true’, the updating buttons (such as ‘Approve’ or ‘Reject’) are disabled, thus preventing the user from making any adjustments. Additionally, a message can be displayed to inform the user that an update is happening. I normally set this value in the form itself since I am aware than an update is about to occur. This is necessary as the workflows take time to start, and the user could open and update the form prior to the workflow setting this value

In my workflows whenever an update is required from the user, the promoted field ‘Outcome’ is set to 0 and the field ‘Completed’ is set to ‘false’. When the user selects a button to approve or reject the data, the system sets this value to 1 or 2 and sets another field ‘Completed’ to ‘true’. This indicates that an update has been made (based on the workflow action ‘Wait for Field Change in Current Item’) and the workflow can resume and make decisions using the chosen selection.

InfoPath will allow you to display links to external files (such as attachments in a list accessed through a Data Connection), but if those URL’s have spaces in them (as many user files do), it could be that when you click on the link you get the ‘Page not found’ message as shown below

This could be happening because you have used the Hyperlink found in the Control Tools instead of the Hyperlink found in the ‘INSERT’ tab in InfoPath. Pretty weird! Anyway, use this method to make sure your linked content displays correctly

Create a Data Connection link to the table that has the attachments.

Make sure to select the attachment in the list of fields as shown below

Drag the table onto your form to create a Repeating Table control

Arrange the columns

Arrange the columns in the format you want and delete any unneeded columns like the ID AND the attachment column (You delete the attachment column as we will add it later and you do not want duplicate links, especially ones that do not function correctly). Insert a column to the Left or Right at the point where you want the Hyperlink. In the image shown below, you will notice that the last column, which I titled ‘Attachment link’ is empty. Your form should look similar to the following

Create the Hyperlink

Place your cursor in the empty cell in the repeating table, switch to the INSERT tab and select the ‘Hyperlink’ button …

This will open up a dialog box for you to complete as follows

In the dialog box for the Link to section, select ‘Data source’ and link the Data Source to the attachment as shown above (in most cases the system will automatically default to the attachments

In the display selection you will probably want to select ‘Data source’. You can then use the Field selector to display the attachment URL or some other detail available in the data connection, or you could use a formula similar to the one below to reduce the size of the URL and only show the last section

substring-after(.,”Attachments/”)

This formula will show the portion of the attachment that follows ‘Attachments/’ – in this case the file name associated with the attachment. This is useful since you do not want to display a URL that is a mile-long and that the users will have problems understanding

Publish the form

Publish the form, and when you click on the link, the image should display with no error

In a previous post (InfoPath – Link to a list item from a URL) i detailed how to open a list item directly from a URL in a form. In some cases (actually many cases) it may be necessary to fill out the new form with data that comes from the calling form. For example, if you are adding attachments, you may want to pre-define the key of the ‘parent’ list

Basically, the ‘calling’ form defines a URL that includes as it’s suffix a parameter that specifies the data that is to be used when pre-populating the form. Also, when the user clicks on the URL, the system will use the ‘Query String (URL) filter’ Web Part to pass this value to an ‘InfoPath Form’ Web Part

Here are the steps involved

Define a field in your calling form to hold the URL you will use

In my example I added a text field called ‘URLAttachment’ as shown below

Click on the fx button to open the Formula dialog box and specify the formula as follows

Key values in this formula:

Lists/FA%20Attachments

This is the name of the list that you would like to link to and open with pre-populated data. My list name is ‘FA Attachments’

/Direct.aspx

The name of the view that the URL must open followed by .aspx. We will define this view later, but if you choose a different name in SharePoint, you will need to modify this value as well

&Details=

This specifies the name of the parameters that are being passed. In my case, I call these values ‘Details’ (This name will be used later in the Filter (URL) Web Part)

Season,”<“,Product,”|”,ID

The value of the ‘Details’ parameters. Since the ‘Details’ parameter passes a single string value, I concatenate my data using ‘<‘ and ‘|’ as delimiters so that I can easily separate the Season, Product and ID from the passed value in the called list. In the online documentation you will notice that it is not a simple task to pass multiple parameters and concatenating all your parameters into a single passed value makes it a simple task

Note. Be aware that WordPress modifies the standard quotation marks based on the display (not edit) font, so if you are cutting-and-pasting, you will need to change them back to standard format

Add a hyperlink field in your form

Add a hyperlink field in your form to link to this URL.

Select the INSERT tab, then click on the Hyperlink button and a screen similar to the following will be displayed

Select the ‘Data source’ radio-set and then use the ‘Select XPath’ button (highlighted above) to select the URL Field (in our case ‘URLAttachment’). Type some text into the Display Text fill-in so that it is clear that the user needs to click on this hyperlink to add an attachment

Your form will now display a Hyperlink to the appropriate list item as shown below in this section pasted from the form

The changes to the calling form have been completed – we now need to make some changes to the called form and the page in which it will be displayed

Add a field to the ‘called’ List that will ‘contain’ the parameters that will be passed in the URL

Create a text field in the list that will be used to contain the passed parameters (this field will not be used for anything else – read my blog on InfoPath – Temporary fields in InfoPath form if you do not want to define additional fields in your list). In my case I created a single line of Text field called PassedParameters as shown below

Define Rules for the field in the ‘called’ form

I then add the field to the called form and add the following rules

Formatting Rule to hide the field

I add a simple formatting rule that will always be true to hide the field as follows (Initially you may want to display the values in PassedParameters to make sure they are coming across correctly – in this case you can add the ‘Hide’ rule to the form after everything is running correctly)

Action Rule to update data when PassedParameters changes

The PassedParameters field will be automatically updated later, but in the form we need to decide what to do with the data it receives. In my case, I use the InfoPath substring-after function to get the ID of the document that this attachment relates to. With this value I can then query the list and set the default data in the form as shown in the screen shot below

Create a view on the list specifically for the URL

In SharePoint, create a view on the ‘called’ list that the URL will call. In my case, I named the view ‘Direct’ (To match my URLAttachment defined in the calling InfoPath form). Initially the View will look something like this (perhaps with some data underneath the headings):

Add the necessary Web Parts to your screen

From the Setting (Gear) icon, select ‘Edit Page’ as shown below

This will open a screen that looks similar to the following. Click on the ‘Add a Web Part‘ link

A screen will be displayed:

In the ‘Categories’ section, select ‘Forms’ and then choose ‘InfoPath Form Web Part’. Click on the ‘Add’ button and the InfoPath Form Web Part will be added to your screen as shown below

Ultimately, this Web Part will display your form. Now we need to add another Web Part to the screen that will move the Parameters from the URL to the PassedParameters field that we created earlier. Click on the add button again as shown above and a screen similar to the following will be displayed

In the ‘Categories’ section, select ‘Filters’ and then choose ‘Query String (URL) Filter’. Click on the ‘Add’ button and the Query String (URL) Filter Web Part will be added to your screen as shown below

Configure the Web Parts to update the PassedParameters field

We now need the web parts to talk to each other. In the InforPart Form Web Part, click on the ‘Click here to open the tool pane’ link. A window will open on the right of the screen. In this window, set the List or Library to the list item that is being called (in my case this is FA Attachments) and set the ‘Content Type’ to ‘Item’. Leave all the other fields defaulted and then click on the ‘OK’ link at the bottom of the window to save your changes.

Once you click OK, you will notice that the input screen of your list is displayed as shown below

Now that the InfoPath Form Web Part has been configured, we need to link the passed URL parameters to this form. Click on the ‘Open the tool pane’ link (Shown in the image above highlighted with a red border). A Screen similar to the following will appear

In the ‘Query String Parameter Name’ enter the name of the parameter that you want to pass to the InfoPath form. In our case, the data we wish to pass (to PassedParameters) is all contained in the parameter ‘Details’. Leave the other fields as they are and click ‘OK’ and the Query String (URL) Filter will change slightly and display a message that the filter is not connected. This is expected

Now, let’s connect the filter. In the top right of the ‘Query String (URL) Filter there is a small drop down indicator. Click on this indicator and you will notice that the menu has a ‘Connections’ option. Select ‘Connections’, then ‘Send Filter Values To’, then ‘InfoPath Form Web Part’, and a screen similar to the following will appear. Select the field ‘PassedParameters’ that we defined earlier (you will notice that other fields from your list are also available)

Click on ‘Finish’.

The job is completed and the ‘Called’ form will now open automatically with the pre-populated data when the link in the ‘Calling’ form is selected

Open your calling form

You are ready to test. Open your ‘Calling’ form and click on the link you defined and the ‘Called’ form should display as shown below (names and places have been changed to protect the innocent!)

It is possible to open another list item directly from the form in another window. This can be useful when you wish to link to related items in another list or add another list item. This is done by building a URL that points to the list that you wish to link to. While the building of the URL can be performed directly in the Hyperlink Data Source, I have found that it is clearer to build the link in a field and then tie the Data source directly to the field.

Add a text field to contain the URL

Add a text field to the form, in the example below I added the field ‘URLAttachment’. Note that the checkbox ‘Refresh value when formula is recalculated’ is checked

Using the fx button,set the default value to one of the following

To open the window in ‘Insert/Add’ mode:

concat(SharePointSiteUrl(), “Lists/<List Name>/item/newifs.aspx”)

Ultimately, the concatenation statement would yield something similar to:

where <FileName> is the name of the XML file without the .xml extension (you may have to store this value in a variable in your form – mine is shown as File_x0020_Name[ID = OriginalCapex] in the figure below).

NB. The code from ‘&Source=’ onwards is optional and is used to close the window automaticallt when the form is closed (See InfoPath – Close window automatically). Ultimately, the concatentation would yield something like

Enter the text that you want the user to see for the prompt (For example: Click here to add an attachment) into a cell as follows

Tie the hyperlink’s ‘Link To Data Source’ to the created field

Highlight the line you typed in the previous step, right click and select ‘Hyperlink …’. A dialog box will open up. In the ‘Link To’ section, click on the radio-set option ‘Data source’ and then click on the Field Selector button to open up the Field Selection Dialog Box. From this box, select the field that you created in the first step above. Click ‘OK’ to save your settings

Publish the form

The link will now appear as a hypertext as shown below. Publish the form and whenever the hyperlinked text is selected, a new window will open with either the New or Edit form displayed

Notes on the above

If your list has spaces in the name, you need to substitute ‘%20’ for each space

This document was originally defined in MS/Word which sometimes changes the character representation when the font changes. To make sure that the quotation marks don’t change (as I have found they often do), make sure to replace any quotation marks copied from this document with new quotation marks

It may be possible to use a similar URL structure in emails to allow the user to click the hyperlink directly from within the email, but I have come across some issues with buttons being enabled and you may have to use a different URL within emails