Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Make a field visible dependent on another fields length - Issue change event


Level 2

Hi all,

I want to make a field named "KdAufPos" visible, if another field named "Kontierungselement" (text field) has the character length 7.

I am using the following javascript code in the change event of the Kontierungselement field:


console.println("START ");

var currentLength = this.rawValue.length;

var kdAufPos = FormServiceRequestConfirmation.mstPageSet1.mstPage1.frmTitle.KdAufPos;


console.println("currentLength "+ currentLength);



function validateFieldValueLength(currentLength){

if (currentLength == 7 ){

console.println("zeichenlänge momentan " + currentLength);

kdAufPos.presence = "visible";


console.println("KdAufNr ist nicht leer " + currentLength);



My issue is that the change event is not triggering correctly. After I am opening the PDF and entering data in the field, the console is showing up but don't display my console.println - I got an error with "TypeError: this.rawValue is null".


Just after exit the field and click in again, I got the console.println and got displayed sometimes the right and sometimes the wrong length...

What is this error about? Why is it that after clicking out and in again the script seems to work and at least do something?

Any tips?

Thanks a lot!



2 Replies


Level 10

Hi Deborah,

You are getting the exception because this.rawValue is null and the null object does not have a length property.

In the change event this.rawValue has not been updated yet.

You probably want to use xfa.event.newText instead.




Level 2

Hi Bruce BR001​,

how to use the xfa.event.newText event? Do you have an example?

So in which standard Adobe events (initialize, change, validate...) do I have to put my code in?

Thanks & regards