Error Building Struct with CreateUUID

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: 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: Does anyone have any idea why using the CreateUUID() function directly in the assignment statement would cause a problem?
Posted by Daniel Short on Mar 26, 2009 at 10:18 AM | Categories: ColdFusion -

7 Comments

Azadi Saryev

Azadi Saryev wrote on 03/26/09 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
Bradley Moore

Bradley Moore wrote on 03/26/09 2:39 PM

Best guess, it has something to do with how structs are created using the curly brackets. This works: This also works: This fails:
Garrett Johnson

Garrett Johnson wrote on 03/26/09 4:59 PM

strange! Must be an odd assignment thing... It likes this though... or
Garrett Johnson

Garrett Johnson wrote on 03/26/09 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/
John Whish

John Whish wrote on 03/27/09 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.
Daniel Short

Daniel Short wrote on 03/27/09 8:06 AM

Yep, I was reading his post yesterday as well. Looks like we're both hitting the same silly issue.
Daniel Short

Daniel Short wrote on 03/27/09 8:06 AM

Yep, my experience exactly.