Sometimes you just need to make sure that the filename of the infopathform is unique when you save it to a library. One method to achieve this is to include the itemid in the filename.
Here is how to do just that:
First you need to create a dataconnection to the library where your infopath forms are saved. This is to aquire the itemID field.
Lateron we are going to determine the last ID and add “1” to it.
Use this formula in the filenamefield:
concat("Formname - ";max(@Id) + 1)