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

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

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.
WeiHelen
WeiHelenAccepted solution
Level 2
Apr 23, 2018 2:33 PM UTC

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

WeiHelen
WeiHelenAuthorAccepted solution
Level 2
Apr 23, 2018 2:33 PM UTC

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?

Translate
WeiHelen
WeiHelenAuthor
Level 2
Apr 19, 2018 6:24 PM UTC

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?

Translate
smacdonald2008
Level 10
Apr 19, 2018 6:12 PM UTC

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

Please post the script you used.

Translate