the only true way to a void this is not to use max(id). I have needed this same scenario many time and these are the steps I take. I have a filename field. On form load I check if it is blank. if blank I set filename using this formula:
concat(substring(xdDate:Now(), 6, 2), "_", substring(xdDate:Now(), 9, 2), "_", substring(xdDate:Now(), 1, 4), "_T_", substring(xdDate:Now(), 12, 2), "_", substring(xdDate:Now(), 15, 2), "_", substring(xdDate:Now(), 18, 2))
this will always give you a unique filename
Onchange of filename I submit the form
query the Library (data source)
get the form id where Filename(promote column) matches Filename (form field)
then I set that value in the form to what ever u need it set. the save is invisible to the user and much better chance of getting ur unique ID