Since you are on SQL Server, you can use the SCOPE_IDENTITY() function to safely capture the last inserted identifier value in the current scope.
The documentation says
SCOPE_IDENTITY (Transact-SQL)
Returns the last identity value inserted into the identifier column to the same extent. Volume is a module: stored procedure, trigger, function, or part. Therefore, two operators are in the same area if they are in the same stored procedure, function, or batch.
When used in two separate ColdFusion tags ( <cfinsert> and then <cfquery> ), the two parties and SCOPE_IDENTITY() will no longer work. Therefore, the INSERT and SELECT must be part of the same batch. Unfortunately, this cannot be achieved with <cfinsert> .
You said that you have many fields in your form post, so I would do something like this:
<cfset fieldNames = "all,relevant,field,names,from,http,post"> <cfset fieldTypes = "INTEGER,VARCHAR,VARCHAR,DATETIME,INTEGER,VARCHAR,VARCHAR"> <cfset fieldNullable = "false,true,true,true,false,true,false"> <cfset fieldCount = ListLen(fieldNames)> <cfloop from="1" to="#fieldCount#" index="i"> <cfparam name="FORM.#ListGetAt(fieldNames, i)#" default=""> </cfloop> <cfquery name="insert" datasource="#yourdatasource#"> INSERT YourTable (#fieldNames#) VALUES ( <cfloop from="1" to="#fieldCount#" index="i"> <cfif i gt 1>,</cfif> <cfset val = FORM[ListGetAt(fieldNames, i)]> <cfset type = "CF_SQL_#ListGetAt(fieldTypes, i)#"> <cfset null = ListGetAt(fieldNullable, i) eq "true" and val eq ""> <cfqueryparam value="#val#" cfsqltype="#type#" null="#null#"> </cfloop> ) SELECT SCOPE_IDENTITY() as NewId </cfquery> <cfdump var="#insert#">