Friday, 16 November 2012

How to name that InfoPath Form

Now I write this blog having implemented this solution over 12 months ago and forgetting recently how I did it.  So as a diary to myself I am writing this blog.

The issue is that I want to name a submitted form with the some text, a value from the form and using the ID value that gets generated. An example of the file name could be ‘Expense Form – Bill Gates – Reference ID 4’. Sounds simple but we also want to submit and save the form each time using this same value.

So to start create a value in the form called ‘FileName’ which is a text field.  Then add a Submit button to your form with two rules applied to it.  The first rule checks to see if ‘FileName’ is an empty value which it will be on first creation and if so sets ‘FileName’ to be the current date and time using now().

The second option on the rule is to submit the form to our form library using a data connection and with the ‘FileName’ as our value for the form submit.  Publish the form to our form library. This now means we can create a form in our library with the current date and time.

To rename this I then create a simple list workflow (not a reusable one) against the form library to first rename the ‘Name’ field, ‘Title’ field and finally a new field called ‘Form Title’.  So now we have a new form created and renamed to how we want it to appear.

Next step is in the form we create a data connection to read the form library data and retrieve all the values we feel would be useful.  Retrieving one or many makes very little difference to the performance.  Make sure the ‘Include data for the active form only’ option is ticked when creating our data connection for retrieving content from the form library.

Once this read data connection is created we can now go back to our ‘FileName’ value in the form and set the default value to retrieve the ‘Form Title’ value from our form library.

Now on the submit button create a new rule which says if the ‘FileName’ is not empty then the rule is to submit the form to our form library using a data connection and with the ‘Form Title’ as our value for the form submit. 

Publish the form to our form library again. This now means we can update a form in our form library with the same name it started with.

This may sound simple but it is invaluable when formulating a name for our form that is unique and incremental.

No comments:

Post a Comment