When creating InfoPath forms directly from the SharePoint list toolbar, all fields that you create in the form are added to the SharePoint list. When you only require a field to hold a temporary value for the duration of time that the form is open, adding theis field to the SharePoint list can complicate the list item with unneeded data. Instead of defining these fields in the SharePoint list, you can create a Data Connection to an XML file that defines the temporary fields you wish to use (I picked this tip up from ‘The Tinkerer’s Journal’ – many thanks Peter Northcott). The values in these fields will NOT be saved with the form. This is how this works
- Create an XML file
The first step is to create an xml file that contains the values needed. Create a file using Notepad called, for example, ‘temporary.xml’ that has the following contents (you can set these to initial values if you need to by following the previous xml example):
<?xml version=”1.0″ encoding=”utf-8″?>
<TemporaryValues>
<ItemCost />
<ItemPrice />
</TemporaryValues>
- Add a data connection to this xml file and set ‘Automatically retrieve data when form is opened’ to true
- Reference the fields within the xml file as you would any other field by using the ‘Insert Field or Group …’ button in your formulas or using an Action to set the values as needed
Note.
The values of these fields are refreshed everytime the form is opened