Answered
Referencing field in a query struct
About 5% of the time I get an error 'Element COMPANYSTATUS is
undefined in Q.' from the code in SNIPPET 1. Can anyone tell me why
I would ever get this error? If the query returns 0 results (which
it may if the user is not logged in and SESSION.User.GetCompanyID()
return 0) it should return false since q.RecordCount is 0. The
problem is I know users in at least some cases are logged in and
the query is returning at least one row. The IF statement should
short circuit on the record count if its 0. If it doesn't then the
comparison for q.CompanyStatus should always be valid. Does any
know why CF flakes out occasionally when referencing
q.CompanyStatus? I see this in other areas as well such as in
SNIPPET 2. The method is called from another CFC where I can
guarantee the passed argument '_company_id' is valid integer and
the SQL should always return 1 result. Why then do I get the error
'Element STATE is undefined in Q.' Is it bad practice referencing
query fields this way?
Thanks In Advance
Thanks In Advance
