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)
Category : InfoPath
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
Getting Initial User Data:2016-05-30T15:54:02,
Query Related Documents:2016-05-30T15:54:02,
Query Item Prices:2016-05-30T15:54:17,
From the above, we can see that there is a problem with the Query on Related Documents since it is taking almost 15 seconds to process based on the time that the ‘Query Item Prices’ is starting
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:
- 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)
- 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
- The user then clicks on the Import button to import the data
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.
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:
|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’|
|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|
|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)|
|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!)