• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

complex object types cannot be converted to simple values

Community Beginner ,
Aug 14, 2023 Aug 14, 2023

Copy link to clipboard

Copied

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
PRODUCT_ID=5332,5333,5334,5335,5336,5337,5338,5339,5340,5341,5342,5343,5344,5345,5346,5347,5348,5349,5350
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.
Please help.


 

 

Views

3.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 14, 2023 Aug 14, 2023

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 f

...

Votes

Translate

Translate
Community Expert ,
Aug 14, 2023 Aug 14, 2023

Copy link to clipboard

Copied

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. 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 14, 2023 Aug 14, 2023

Copy link to clipboard

Copied

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:

 

array118632186431865418665186761868718698187091871101872111873121874131875141876151877161878171879181880

 

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 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 14, 2023 Aug 14, 2023

Copy link to clipboard

Copied

This is the cf var dump that it is showing

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 14, 2023 Aug 14, 2023

Copy link to clipboard

Copied

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:

 

sameFormFieldsAsArray="false"

 

 

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. 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 15, 2023 Aug 15, 2023

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

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. 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

I am on the latest 9 i believe so its clearly still and issue. As soon as i
added that flag to cfapplication problem was solved

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

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.) 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

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.

  • I wonder if you may have code in some parent application.cfm or application.cfc that may have been setting the value to TRUE (or yes or on). When you "solved this" the other day, did you do it by ADDING this setting to your existing application.cfc or cfm? Or did you create one anew? 
  • You could do a cfdump of the cf function, getapplicationmetadata(), which shows what app-level settings are configured for your current app--whether you set them or inherit them as CF defaults. That may be of some use for you to consider using.
  • I have updated my reply that you kindly marked as "the answer" to clarify a couple of those last points, for the sake of those who may find the thread and only read the answer, rather than the rest of these comments. 🙂
  • FWIW, I offer code you could run to see this behavior, which you can see and run at Adobe's cffiddle.org site, which elts you run code against CF2023, 2021, and 2018. I offer the code via this link, though because it requires both a test page and an application.cfc, it's what cffiddle calls an "application", and as such one will need to login (via google, as offered there) in order to see or run the code

 

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.


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

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. 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 18, 2023 Aug 18, 2023

Copy link to clipboard

Copied

LATEST

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 15, 2023 Aug 15, 2023

Copy link to clipboard

Copied

That's good to know! Thanks!

 

Dave Watts, Eidolon LLC

Dave Watts, Eidolon LLC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation