Mar 26 2009
This is more for myself than anyone else, but I hit an odd snag in ColdFusion this morning. I got an error when trying to create a new structure member using a CreateUUID() function and ColdFusion's shorthand structure notation. The following code fails:
<cfset CurrentOrder.Cart[CreateUUID()] = {type = "foo"} />
The error I receive is that "Element 435A2A8C-0B35-C81F-4F36BE50E1B8F394 is undefined in a CFML structure referenced as part of an expression." Well duh! I'm trying to create it!
So I changed the code to this, which works perfectly:
<cfset myvar = CreateUUID() />
<cfset CurrentOrder.Cart[myvar] = {type="foo"} />
Does anyone have any idea why using the CreateUUID() function directly in the assignment statement would cause a problem?

Mar 26, 2009 at 2:36 PM i do not exactly know why, but:
a) i think it has something to do with the way cf evaluates things with implicit array/structure notation;
b) it is definitely related to http://www.bennadel.com/index.cfm?dax=blog:1545.view
Azadi
Azadi Saryev Says:
Mar 26, 2009 at 2:36 PM i do not exactly know why, but:<br />a) i think it has something to do with the way cf evaluates things with implicit array/structure notation;<br />b) it is definitely related to <a rel="nofollow" href="http://www.bennadel.com/index.cfm?dax=blog:1545.view">http://www.bennadel.com/index.cfm?dax=blog:1545.view</a><br /><br />Azadi
Mar 26, 2009 at 2:39 PM Best guess, it has something to do with how structs are created using the curly brackets.
This works:
<cfset foo[ createUUID() ] = true />
This also works:
<cfset foo[ createUUID() ] = {} />
This fails:
<cfset foo[ createUUID() ] = { value = true } />
Mar 26, 2009 at 4:59 PM strange! Must be an odd assignment thing...
It likes this though...
<cfset foo = {type = "foo"} />
<cfset CurrentOrder.Cart[createUUID()] = foo />
or
<cfset CurrentOrder.Cart[createUUID()] = {} />
Garrett Johnson Says:
Mar 26, 2009 at 4:59 PM strange! Must be an odd assignment thing...<br /><br />It likes this though...<br /><br /><cfset foo = {type = "foo"} /><br /><cfset CurrentOrder.Cart[createUUID()] = foo /><br /><br />or<br /><br /><cfset CurrentOrder.Cart[createUUID()] = {} />
Mar 26, 2009 at 5:11 PM Appears to be a struct literal problem... not a uuid issue...
http://www.barneyb.com/barneyblog/2008/07/14/coldfusion-struct-literals-fail-again/
Mar 27, 2009 at 3:59 AM This is a wild stab in the dark, but I wouldv'e thought that it is something to do with the order that ColdFusion evaluates your code. I think that it is probably doing the "currentOrder.Cart" before it generates the CreateUUID() key name.
Mar 27, 2009 at 8:06 AM Yep, I was reading his post yesterday as well. Looks like we're both hitting the same silly issue.
Mar 27, 2009 at 8:06 AM Yep, my experience exactly.