An undefined element in a Java object of type coldfusion.runtime.J2eeSessionScope

I have code that uses precisionEvaluate () on a session variable, but when I call the function, an error like this occurs:

The emp_nextid_ANE_801 element is undefined in a Java object of type coldfusion.runtime.J2eeSessionScope.

There is a condition in the code to check this session variable with structKeyExists (), but it still shows an error. Does anyone know why these are still errors?

Here are some of the code:

if( structKeyExists(session,'emp_nextid_#app().getCurrentAgentID()#_#officeID#') 
   AND  val(session['emp_nextid_#app().getCurrentAgentID()#_#officeID#']) GT 0) {

    var nextID = precisionEvaluate(session['emp_nextid_#app().getCurrentAgentID()#_#officeID#']);
    var qData = new Query();
    var sql = "SELECT 1 FROM Employee
               WHERE pers_id = :nextid";
    qData.addParam(name="nextid", value=nextID, cfsqltype="CF_SQL_BIGINT");
    var result = qData.execute(sql=sql).getResult();
}

      

+3


source to share


1 answer


Call, app (). getCurrentAgentID () can generate values ​​that change dynamically. You can improve the code snippet anyway:



var key = 'emp_nextid_' & app().getCurrentAgentID() & '_' & officeID;
if( structKeyExists(session,key) AND val(session[key]) GT 0) {

    var nextID = precisionEvaluate(session[key]);
    ...
    etc.
}

      

+1


source







All Articles