Variables inside loop not assigning properly
Hey Guys,
I am probably making a totally novice error here somewhere, but hell if I can see it. Basically I have some code that loops over a query, inside that query I assign some information into an array. Probelm is my array comes out completly filled with information from the last record of the query. So for example if my query had the people
Name
1 Tom
2 Frank
3 Jones
I want my array (which is actuall an array of structures) to have the info like
1.Name:Tom
2.Name:Frank
3.Name:Jones
but I'm ending up with
1.Name:Jones
2.Name:Jones
3.Name:Jones
All elements take the same info as the last record in the query. If you still don't quite follow here is a link that shows an actual query, and the resulting structure.
http://portal.fpitesters.com/queryexample.cfm
And here is the relevent code.
<cfloop query="CampaignMembers">
<cfset LoopCounter = LoopCounter + 1>
<cfset batchcounter = batchcounter + 1>
<cffile file="C:\Website\Portal\Secure\Reports\IVRLogs\Calls_For_#url.studyid#.Log" action="append" addnewline="yes" output="Calling #Contact_IVRPHONE__c# At #timeformat(now())#">
<cfset GuidArray[LoopCounter] = server.AngelAPI.PlaceCallToAngel(CampaignMembers.Contact_Name,CampaignMembers.Contact_PID__c,CampaignMembers.Contact_IVRPHONE__c,url.AngelSite,url.MaxWaitTime)>
<cfset GuidArray[LoopCounter].ContactID = CampaignMembers.Contact_ID>
<cfset GuidArray[LoopCounter].CampaignMemberID = CampaignMembers.ID>
<cffile file="C:\Website\Portal\Secure\Reports\IVRLogs\Calls_For_#url.studyid#.Log" action="append" addnewline="yes" output="Placed Call: GUID Is #GuidArray[LoopCounter].GUID#. Called #Contact_IVRPHONE__c#. Status is: #GuidArray[LoopCounter].Message#">
<cfif batchcounter EQ form.batchsize>
<cffile file="C:\Website\Portal\Secure\Reports\IVRLogs\Calls_For_#url.studyid#.Log" action="append" addnewline="yes" output="Finished Batch #maincounter/url.batchsize# At #timeformat(now())#">
<cffile file="C:\Website\Portal\Secure\Reports\IVRLogs\Calls_For_#url.studyid#.Log" action="append" addnewline="yes" output="------------------------------------------------------------">
<cffile file="C:\Website\Portal\Secure\Reports\IVRLogs\Calls_For_#url.studyid#.Log" action="append" addnewline="yes" output=" ">
<cfoutput>#repeatString(" ", 73729)#</cfoutput>
<cfflush>
<cfif url.waittime GT 0 and maincounter LT CampaignMembers.RecordCount>
<cffile file="C:\Website\Portal\Secure\Reports\IVRLogs\Calls_For_#url.studyid#.Log" action="append" addnewline="yes" output="Started Waiting At #timeformat(now())#">
<CFTHREAD ACTION="SLEEP" DURATION="#url.waittime*60000#"></cfthread>
<cffile file="C:\Website\Portal\Secure\Reports\IVRLogs\Calls_For_#url.studyid#.Log" action="append" addnewline="yes" output=" ">
</cfif>
<cfset batchcounter = 0>
</cfif>
<cfset maincounter = maincounter + 1>
</cfloop>
