Ok, I just tried calling the same method directly from a CF template and the structures populated properly. It is only when I am calling it as a webservice that the structs are empty.
On Sat, Dec 20, 2014 at 12:10 PM, Dean Lawrence <dean...@gmail.com> wrote: > Thanks Rodney. I was hoping that what you suggested would work, but > unfortunately, it did not. I tried it in both ACF 10 and ACF 11. I'm still > left with empty structs inside the array. > > On Sat, Dec 20, 2014 at 11:22 AM, Rodney Enke <renk...@gmail.com> wrote: > >> >> I believe you are just passing a reference of the tmpAddress to the array, >> so it is being overridden with each loop. Try the following to insert a >> copy of the structure into the array instead: >> >> ArrayAppend(results.Deal.addresses,duplicate(tmpAddress)); >> >> - >> Rodney >> >> On Fri, Dec 19, 2014 at 4:39 PM, Dean Lawrence <dean...@gmail.com> wrote: >> >> > >> > I have a remote method which is retrieving a deal object, populating a >> > structure and returning it to the client requesting it. This is all well >> > and good. However, the deal object has multiple address objects >> associated >> > to it. When looping over these addresses, I am having trouble adding >> them >> > to an array. Here is my code: >> > >> > for (Address in Deal.getAddresses()){ >> > tmpAddress.street = Address.getStreet(); >> > tmpAddress.street2 = Address.getStreet2(); >> > tmpAddress.city = Address.getCity(); >> > tmpAddress.state = Address.getState(); >> > tmpAddress.postalcode = Address.getPostalcode(); >> > tmpAddress.phone = Address.getPhone(); >> > ArrayAppend(results.Deal.addresses,tmpAddress); >> > } >> > >> > The problem that I am having is that the results.Deal.addresses key >> ends up >> > with an array of empty structures, the total number matching the total >> > addresses associated to this deal. So in my test case, the deal that I >> am >> > working on has a single address, so the results.Deal.addresses key is an >> > array with on empty structure in it (no keys). However, if I don't try >> to >> > append to the array by doing this: >> > >> > for (Address in Deal.getAddresses()){ >> > tmpAddress.street = Address.getStreet(); >> > tmpAddress.street2 = Address.getStreet2(); >> > tmpAddress.city = Address.getCity(); >> > tmpAddress.state = Address.getState(); >> > tmpAddress.postalcode = Address.getPostalcode(); >> > tmpAddress.phone = Address.getPhone(); >> > results.Deal.addresses = tmpAddress; >> > } >> > >> > The results.Deal.addresses key is now a struct and all the address keys >> > assigned properly, so I know the tmpAddress struct is being populated >> > properly. Does anyone have any thoughts as to what might be going on? I >> am >> > running ACF 10 and yes, I have var scoped the results, Deal and >> tmpAddress >> > variables at the top of the method. I also tried adding "local" to the >> > Address variable in the for loop, but it did not help. >> > >> > Thansk, >> > >> > -- >> > >> > [image: profile picture] *Dean Lawrence* >> > *President* >> > Internet Data Technology >> > *Phone:* 888-438-4381 x701 >> > *Web:* www.idatatech.com >> > *Email:* d...@idatatech.com >> > Programming | Database | Consulting | Training >> > >> > >> > >> >> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359867 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm