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

How to get value less than 0 = 0

Avatar

Former Community Member

I am trying to get a formula to do two operation in one field something like:

form1.#subform[0].yes1.qn1::calculate - (JavaScript, client)

(p1-s1)

then if the value is less than "0" the the value = "0"

what I have so far is not working, any help is greatly appreciated.

if

(this.rawValue < 0)

this.rawValue

= 0;

Thank you.

1 Accepted Solution

Avatar

Correct answer by
Level 10

I placed the following code in the Calculate event of qn4 field.. Language FormCalc..

If this is NOT what you are trying to do, then please explain in detail..

if((p4-s4)==0)then
$.rawValue = 0;
else
$.rawValue = (p4-s4);
endif

Thanks

Srini

View solution in original post

5 Replies

Avatar

Level 10

Try the parseInt function to convert the String to Integer. Otherwise change your control Type from TextField to NumericField.

     parseInt(this.rawValue)<0

Thanks

Srini

Avatar

Former Community Member

Srini,

Thanks for the reply, although I still cannot get this to work.

I changed the fields to numeric and it still is not working.

Avatar

Level 10

Would you be able to send the form to LiveCycle9@gmail.com, so I can have a look at it.

Please mention where the issue is?

Thanks

Srini

Avatar

Correct answer by
Level 10

I placed the following code in the Calculate event of qn4 field.. Language FormCalc..

If this is NOT what you are trying to do, then please explain in detail..

if((p4-s4)==0)then
$.rawValue = 0;
else
$.rawValue = (p4-s4);
endif

Thanks

Srini