I am looping through a query to create a list of part numbers to populate a list of part numbers:
<cfset binlist = "" >
<cfset a = 1 />
<cfloop query="getParts">
<cfif a >
<cfset binlist = getParts.binnum>
<cfset a = 2 >
<cfelse>
<cfset binlist = binlist & "," & getParts.binnum >
</cfif>
</cfloop>
I want to add the binlist element to an element of an array in order to populate a spreadsheet:
<cfset aColumns = [ partnum, shortchar08, partdescription, binlist, inventory.currinv , staged.stagedqty, alloc.allocqty, available, shelfCount, shipdtl.shipqty, getNumberofStores.numStores, tordered, APS, paddedLeadTime, LWM, storesRemain] />
<!---add the column data to the spreadsheet--->
<cfset SpreadsheetAddRow(SpreadsheetObj, ArrayToList(aColumns)) />
1 part can be in multiple bins. It works in my CF output page, but not in the spreadsheet that I am trying to generate to show the multiple bins for a part
The spreadsheet generated only contains one bin per part and not multiple bins for the parts that do have multiple bins.
I think (if I understand your logic) what you are attempting to do is simply one line of code in Coldfusion:
Upon looking at your code further, it looks like you are embedding a list into an Array, and then converting the array to a list. If you have a comma-separated list, then stick that in the middle of another comma-separated list, they’re going to just be interpreted as individual elements rather than a set.
See what happens if you change your delimiter to something other than a comma so that it doesn’t get confused with the larger list:
Update:
OK, I see you have a part grouping problem. Let me update my solution:
Basically, you don’t mix CFOUTPUT and CFLOOP. If you’re using CFOUTPUT to group, the inner CFOUTPUT is needed (minus the group parameter) to get your inner grouping.