I am having issues with Nulls. This is the error I...
# lucee
m
I am having issues with Nulls. This is the error I am getting when trying to read an XML and there are null elements.
Lucee 5.4.3.2 Error (expression)Messagethe value from key [FlatNumber] is NULL, which is the same as not existing in CFMLStacktraceThe Error Occurred in
C:\Projects\Zoopla\RealtimeLucee\root\Coldfusion\Fusebox\realtime\currentbuild\valuation\api\act_createxml.cfm: line 90
>
88: <cfset columnName = thisKey>
>
89: <cfif isNull(i[thisKey]) or not isdefined("i[thisKey]")>
>
90: <cfset i[thisKey] eq "1">
>
91: <cfdump var="#i[thisKey]#">
>
92: <cfabort>
If I switch on Complete Support in Lucee admin it breaks other parts of the site so I need to keep on partial support. How can i get around this and use it only for this particular template. Or is there another workaround. I'm checking for NULL as you can see in the above example and trying to set it to a value of one but it still breaks and presents me that error. :-(
a
You are checking to see if
i[thisKey]
is null, and then go ahead and use it in a boolean expression anyhow. You're basically going
null eq "1"
. I suspect you intend for that to be an assignment, not a boolean expression. Unrelated to your question, but you can't do
isdefined("i[thisKey]")
.
isDefined
only takes a variable name, not just [any expression]. What you want to use there is
structKeyExists
, but the null check does the same thing anyhow,so just get rid.
i
is a terrible variable name for a struct, btw.
m
cheers @Adam Cameron sorted it thanks for your help
👍 1