Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Changing presence based on value of another calculated field

Avatar

Level 1

Hi,

I am trying to hide a signature field if the value of another calculated field is less than a certain value.  I am attempting to use:

 

if (TotalRelUpper.rawValue<150) then

signature.presence="invisible"

endif

If I put this formcalc statement in the click section of the calculated field, the signature field presence will change state, but I want it to automatically change state based on the calculated value.

Ideas appreciated.

Thanks!

7 Replies

Avatar

Level 10

Did you try placing the code in the Calculate event of the field?

Thanks

Srini

Avatar

Level 1

Srini,

Thanks for the info.  When I place the following code in the calculate section, the calculation does not work.  The signature field is invisible and no value will make it visible.

Thanks,

Stan

 

form1.#subform[0].TotalRelUpper::calculate - (FormCalc, client)

 

 

TotalRelUpper.rawValue=UpperNFC.rawValue+UpperExp.rawValue

 

if (TotalRelUpper.rawValue<150) then

VPsignature.presence="invisible"

endif

Avatar

Level 10

Stan,

     You are missing the else part in the code..

  

TotalRelUpper.rawValue=UpperNFC.rawValue+UpperExp.rawValue

 

if (TotalRelUpper.rawValue<150) then

     VPsignature.presence="invisible" 

else    

     VPsignature.presence="visible"

endif

Thanks

Srini

Avatar

Level 1

Srini,

Even with the else statement, the code does not work in the calculate section.

form1.#subform[0].TotalRelUpper::calculate - (FormCalc, client)

TotalRelUpper.rawValue=UpperNFC.rawValue+UpperExp.rawValue

if  (TotalRelUpper.rawValue>150)then

    VPsignature.presence="visible"

else

    VPsignature.presence="invisible"   

endif

The calculated field is read only and is the sum of two other fields filled in by the user.  I want to have a signature field appear or disappear based on the value in the calculated field.

Thanks,

Stan

Avatar

Level 7

try putting it in the layoutReady event

Avatar

Level 1

Thanks for the suggestion.  I tried placing the code in several of the layoutready events, to no avail.  There has to be a simple solution, but as a novice in form building, it eludes me.  Other inputs are welcome.

Thanks

Avatar

Level 10

Hi Stan,

You just need to make sure the last expression evaluated to the calculate event it the one you want in the result, so you can do;

TotalRelUpper.rawValue=UpperNFC.rawValue+UpperExp.rawValue

if  (TotalRelUpper.rawValue>150)then

    VPsignature.presence="visible"

else

    VPsignature.presence="invisible"   

endif

TotalRelUpper.rawValue

The last line can set there like that, or you could do;

var total=UpperNFC.rawValue+UpperExp.rawValue

if  (total>150)then

    VPsignature.presence="visible"

else

    VPsignature.presence="invisible"   

endif

TotalRelUpper.rawValue=total

Regards

Bruce