I am moving an old application which is on a CF11 install to my CF2021 install.
the code has worked fine for 10 years under CF11
i have code where after i am adding a product to my cart it its updating the database with the cart product information. it is running this code as part of a UPDATE cfquery and upating a user table:
SET PreviousProduct_ID = '#Listfirst(Form.Product_ID)#',
CF is complaining -
Complex object types cannot be converted to simple values.
but it is not a complext object it is a simple list productid numbers with commas
this is the variable output in the CF debug
that is a list? not a complex object? works fine in CF11 but not in 2021 and i can not for the life of me fiture it out.
Well, we have to take your word for it that the error is indeed referring to that variable. Can you confirm that somehow? For instance, you could put a <cfabort> before the cfquery doing the sql update. Does the error still happen? If not, that's NOT what's causing the error.
Second and as important, don't rely on the debug output. At the same time as the above, and before the cfabort, put in a <cfdump var="#form.Product_ID#"> to see what is in that var right before trying that update. There are reasons the two results could vary.
so i put the abort right before the query and as suspected there was no error - i would not expect there to be because the line that caused the error did not run so thats good.
Now i did the var dump and i get this:
so it appears it is an array? not sure how that is but it worked in CF11 so CF11 must have allow this and now is'nt?
but i dont know how to fix it
Ok, there you go. It IS indeed a complex object, an array as you note. As for how it's happening, it was a change Adobe curiously (and quietly) introduced a couple of years ago (but then soon reverted). In CF2018 update 11 and CF2021 update 1, they started treating the multiple values of any form fields that had the same name as an array, instead of as a list as in the past. That seems to be what you're experiencing. This was reverted in CF2018 update 12 and CF2021 update 2.
Technically, the feature is an old one, introduced in CF10, where Adobe also introduced a way to control that behavior, either with a cfapplication attribute for those using that and/or application.cfm, or as a property of application.cfc for those using that, called sameFormFieldsAsArray. Initially it defaulted to False. Only for that one update did it revert to defaulting to True. Since then, it again defaults to false.
In any case, if you're getting an array and want a list, you'd want to set it to false. Don't make a mistake that I and many have, of leaving off the "s" after "field". It's:
And if you want to view what value is affecting your application, use cfdump to view the result of CF's getapplicationmetadata() function, which will report this sameformfieldsasarray being yes or no, depending on your setting or the default (it does not indicate if settings are set or picked up as defaults).
For more on the sameformfieldsasarray issue from that timeframe in 2021-2022, see another discussion thread back then, and my comment offering this solution then https://community.adobe.com/t5/coldfusion-discussions/coldfusion-2018-update-11-error/m-p/11954596#M...
Let us know how it goes.
That worked. I want to thank you very much. I do have to say the lack of documentation on this is a shame considering they charge so much for a license in the first place. I so appreciate this community and your help. Thank you!
Rick, glad to have helped. But note that it IS documented, at https://helpx.adobe.com/coldfusion/cfml-reference/application-cfc-reference/application-variables.ht.... It was also documented in the update technotes when the change was made (which link I had pointed out in the other thread). Or did you have in mind some other way it could/should be documented?
BTW, I wanted to hear first if this would solve things for you. Now that you've confirmed it does, I'll say it's odd that you're seeing this. The very next update (2 of cf2021 and 12 of cf2018) reverted the behavior to default this new capability to false.
So since you've had to force it to false, can you please confirm what update you're on? You can see it many ways, whether the cf admin "settings summary" page, or the debug output on each page (if enabled), or in the cf server.coldfusion variable.
i am using 2021 update 9 so it was still an issue. As soon as i added that flag to cfapplication the problem was solved.
Thanks for clarifying. I understood that you added the flag to solve things. The question now is why you had to, and if that's somehow unique to you. I've not heard of others complaining that the behavior had switched again. (I'm on a phone so can't test this myself.)
you helped me so i am happy to help if there is anything i can do to assist. I have no idea why if i am on 9 and it was corrected in 2 why id get that message.
Rick, I have now confirmed that the default is indeed sameformfieldsasarray being FALSE (or no) for CF2021 since update 2 and CF2018 since update 12 (just as it was for CF11 and 10, where it was first inroduced). It was only in CF2021 update 1 and CF2018 update 11 where Adobe reverted that unexpectedly to TRUE,
So I'll offer a couple of things, as you're interested.
But I'll also understand if you may decide that we're now beating a dead horse. Again, I leave the details in the hope of helping others who may find this in the future.
i can say with 100% certainty i have no other application .cfm (I dont use cfc's on this server). The folder the code is in is the top level folder.
I litereally ran the code and saw the array like i sent you even though CF11 treated it as a list. i then added the tag and actually created a new cfapplication as i never used that tag in my application.cfm file save it and refreshed the screen and the dump cam back as a proper list. So it is still very much a bug at least in my version.
Ok on your first point. On the second, please see the other bullets in my reply. Or let it go if you prefer. I'll say I doubt there's a bug, just an explanation to be determined. I've offered in my last reply at least two ways to dig in further if you want.
Okay in the interest of me understanding better and helping the community i found out what is going on using your cfdump
basically your right on the server level it was fixed - BUT in my application.cfm file you MUST have an empty <cfapplication> tag
so the server will not default to false just by putting code for such. the code MUST be in a folder with a a <cfapplication> tag you do not need to have the sameFormFieldsAsArray="false"> it will default to false if the tag is there but without it it fails.
That's good to know! Thanks!
Dave Watts, Eidolon LLC