Custom getter function; Could not resolve property / Property not present

Hi all

I have a persistent cfc with a custom getter function for the ACTIVE property, that looks like this:

component
entityname = “Accreditation”
extends = “ORMBaseAccreditation”
persistent = “true”
table = “T_ACCREDITATION”
readonly = “false”
cachename = “userCache”
cacheuse = “transactional”
output = “false”
{
property name=“ACCR_KY” column=“ACCR_KY” type=“numeric” ormtype=“integer” fieldtype=“id” generator=“sequence” params="{sequence=‘T_ACCREDITATION_SEQ’}";
property name=“TERMS_ACCEPTED_BO” column=“TERMS_ACCEPTED_BO” type=“string” ormtype=“char”;
property name=“T_PERSON” fieldtype=“many-to-one” cfc=“Person” fkcolumn=“PERS_KY” lazy=“true” missingRowIgnored=“true”;

property name=“T_ACCRE_WKF” fieldtype=“one-to-many” cfc=“AccreditationActivity” fkcolumn=“ACCR_KY” lazy=“true” inverse=“true” orderby=“ACCR_KY DESC”;

property name=“ACTIVE” persistent=“false” setter=“false”;

boolean function getActive(){
var isActive = false;
var notValidStatuses = “ACCEPTED,REFUSED,REVOKED”;
var endDate = this.attr(‘ACCREDITATION_END_DT’);
var status = this.attr(‘STATUS_DOMA_KY’);

if( (isNull(endDate) || (!isNull(endDate) && dateDiff(“d”, now(), this.attr(‘ACCREDITATION_END_DT’)) >= 0) ) && !isNull(status) ) {
return !listFind(notValidStatuses, status.attr(‘CODE_CD’));
}

return false;
}

}

I want to retrieve all ACCREDITATIONS for a person that are active. Retrieving by person works fine, but I can’t get the active ones.

Like this;

arrActiveAccreditations = entityLoad(“Accreditation”, {t_person = this, active = true});

I get this:

“Property ACTIVE not present in the entity”

And like this:

arrActiveAccreditations = ORMExecuteQuery(

“SELECT accr.ACCR_KY FROM Accreditation as accr WHERE accr.T_PERSON.PERS_KY=:persKy AND accr.ACTIVE=:bactive”

, { persKy=this.getpers_ky(), bactive=true } //

);

I get this:

“could not resolve property: ACTIVE of: Accreditation”

Can anyone see where I’m going wrong?

Hi Michael,

Try to initialize the variables in constructor

Example

function init(){

ACTIVE = false;
}

I came across similar problem with CF9.

or use the default property

Hi Sana, Andrew

I tried both your suggestions - makes no difference.

It’s like the ACCREDITATION object is simply saying, “I don’t have a property called ACTIVE”. Yet if I amend the entityLoad() call to just this (omitting the ACTIVE clause):

arrActiveAccreditations = entityLoad(“Accreditation”, {t_person = this});

and I dump the resulting array, I can see in the app.model.Accreditation, under Properties, there is ACTIVE = YES.

Do I need to do something extra with the ACTIVE property to make it ‘known’ to the object??

I haven’t tried it, but does ORM functions work on no persistent properties I would say no, for obvious reasons.