Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Displaying calculated field only when data exist

Avatar

Level 3

Hello,

Is there a way to display my calculated value only when the data entry field is being used. For instance, if I have several fields vertically aligned, I don't want to display a bunch of zeros if their data fields are not being used.

THANK YOU!!!!

1 Accepted Solution

Avatar

Correct answer by
Level 10

You need to write the script in the Calculate event of Field2.

Set the language to FormCalc.

     if(numPeople.rawValue ne null) then

               numPeople * 12

    endif

My previous response shows 2 ways of writing the same script. One in FormCalc and other in JavaScript..

Thanks

Srini

View solution in original post

4 Replies

Avatar

Level 10

You can check for the rawValue in the Calculate event before any script.

Event: Calculate

//FormCalc

   if(Field1.rawValue ne null) then

     // write your script here

   endif

//JavaScript

if(this.rawValue != null){

   // write your script here

}

Thanks

Srini

Avatar

Level 3

Thank you for your response. Though, I'm a bit confused...

My form has fields as following:

   Field1 (user input) Field2 (calculated). Do I place both scripts in the Calculate event? Do the scripts go in field1 or field2?

My actual formula reads: numPeople * 12 and it's placed in Field2

THANK YOU SO MUCH!!

Avatar

Correct answer by
Level 10

You need to write the script in the Calculate event of Field2.

Set the language to FormCalc.

     if(numPeople.rawValue ne null) then

               numPeople * 12

    endif

My previous response shows 2 ways of writing the same script. One in FormCalc and other in JavaScript..

Thanks

Srini

Avatar

Level 3

Srini,

Thank you for your assistance, I really appreciate it. I'm still getting the "$0.00" in Field2 when there is nothing in Field1 though.

Thank you!!!