Expand my Community achievements bar.

SOLVED

How can I add an error message when "b - a > a" in an AEM form

Avatar

Level 2

I have a final totalMileage calculation at the end of a form by using... ::calculate - (FormCalc, client)

So far the summary syntax  is worked as sum(Table3.Row3[31].TotalEnd - Table3.Row3[31].TotalBegin)

I'd like to add an If statement with an error message,  if the sum()  < Total Begin , then message show up, otherwise show the sum numbers.

I tried both JavaScript and FormCalc, no solutions, please give me some hint? Thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 2

smacdonald2008 Employee

Thanks!

I got this resolved.  I chanced the event from Calculate to exit.  The script works well!

form1.MileageLogSubform.Table3.Row3[0].End::exit - (JavaScript, client)

if (this.rawValue < Begin.rawValue)

{

app.alert("Error! You need to enter valid Ending");

}

Where can I find the definition about all of the JavaScript event types?

View solution in original post

3 Replies

Avatar

Level 10

When you used a scriptingh langauge supported by AEM Forms, what was the response?

Please post the script you used.

Avatar

Level 2

I added the if statement into filed end as following. ( add error check to the end summary filed may be complicated )

Instead , I add the error check to the data entry filed. same logical , end > begin.  so if end value is < begin , error message shows.

The script is at following:

form1.MileageLogSubform.Table3.Row3[0].End::calculate - (JavaScript, client)

                                if (this.rawValue < Begin.rawValue)

                                {

                                                app.alert("Error! You need to enter valid Ending, at least > Begin mileage");

                                }

However,  I went to Preview PDF to test, I type the number into Begin field, but when I click the end file without type any number , the error message has pop out.

And also, after the error message the End value is 1, and it can not be changed.

May I need add type value script first then check compare the value with the begin.rawValue?

Almost there. At least the error message shows up.  

Would let me know how to add this.rawValue at End field first?

Avatar

Correct answer by
Level 2

smacdonald2008 Employee

Thanks!

I got this resolved.  I chanced the event from Calculate to exit.  The script works well!

form1.MileageLogSubform.Table3.Row3[0].End::exit - (JavaScript, client)

if (this.rawValue < Begin.rawValue)

{

app.alert("Error! You need to enter valid Ending");

}

Where can I find the definition about all of the JavaScript event types?