ColdFusion 11 code no longer works for ColdFusion 21
Hello,
I have migrated our Coldfusion apps from a server running ColdFusion 11 to 21, most have been successful but I am having difficulty resolving one error and would appreciate if anybody has any advice.
The block that errors is:
<CFLOOP INDEX="i" FROM="1" TO="#listlen(Form.Net)#">
<CFSET #Net# = #listgetat(Form.Net,i,",","true")#>
<CFSET #vat# = #listgetat(Form.vat,i,",","true")#>
<CFSET #Dep# = #listgetat(Form.dep,i,",","true")#>
<cfif #len(Dep)# eq "0">
<cfset #Dep# ="XX">
</cfif>
<CFSET #Act# = #listgetat(Form.act,i,",","true")#>
<cfif #len(Act)# eq "0">
<cfset #Act# ="Null">
</cfif>
<CFSET #Prj# = #listgetat(Form.prj,i,",","true")#>
<cfif #len(prj)# eq "0">
<cfset #prj# ="Null">
</cfif>
<CFSET #Loc# = #listgetat(Form.loc,i,",","true")#>
<cfif #len(loc)# eq "0">
<cfset #loc# ="">
</cfif>
<CFSET #PO# = #listgetat(Form.po,i,",","true")#>
<cfif #len(PO)# eq "0">
<cfset #PO# =#variables.MaxPO#>
</cfif>
<CFSET #LineDescr# = #listgetat(Form.LineDescr,i,",","true")#>
<cfif #len(LineDescr)# eq "0">
<cfset #LineDescr# ="XXXX">
</cfif>
I am new to ColdFusion and picking up somebody else's code so I am not 100% sure where the issue lies but the from research it may be the change in CFLOOP's behaviour in the 2016 release?
This is how the data is input-

The user should be able to input as many lines as nessecary, but should only have to populate Dep, Project etc on the first line, and it should be copied for all subsequent lines, only Net and VAT should be required for every line. This works as expected on CF11.
The CF21 page works for single lines but errors when more than one line is entered. The error code is as follows:
Mar 28, 2023 15:33:55 PM Error [ajp-nio-127.0.0.1-8020-exec-15] - Invalid list index 2.In function ListGetAt(list, index [, delimiters]), the value of index, 2, is not a valid as the first argument (this list has 1 elements). Valid indexes are in the range 1 through the number of elements in the list. The specific sequence of files included or processed is: "path", line: 243
<CFSET #Dep# = #listgetat(Form.dep,i,",","true")#> is line 243.
The code works as expected on the old ColdFusion 11 server and only errors on the new server, has anybody had a similar issue before?
Any advice or guidance would be greatly appreciated.
