How can I add an error message when "b - a > a" in an AEM form | Community
Skip to main content
WeiHelen
Level 2
April 19, 2018
Solved

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

  • April 19, 2018
  • 3 replies
  • 1744 views

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!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by WeiHelen

smacdonald2008

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?

3 replies

smacdonald2008
Level 10
April 19, 2018

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

Please post the script you used.

WeiHelen
WeiHelenAuthor
Level 2
April 19, 2018

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?

WeiHelen
WeiHelenAuthorAccepted solution
Level 2
April 23, 2018

smacdonald2008

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?