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

Subtracting two fields and button

Avatar

Level 1

I am trying to subtract Text11 from text 11.1 and total it in Text11.2, I have tried different Java and FromCals. PLEASE HELP!!!

Also is there a way to add a button that is linked to the pencil tool on a form?

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Hmmm. Try removing the formatted value option in the Time2Num functions.

var Interval = Time2Num(StopTask) - Time2Num(StartTask)

Steve

View solution in original post

7 Replies

Avatar

Level 1

I uploaded the form. So you know whick Items I am talking about I circled them. Let me know what you come up with. Also is there a way to add documents to this? Everytime I try to do anything to it I get the error about it being an xml form.

Thanks

Avatar

Former Community Member

1) Calculating total mileage. I would avoid using form field names that include a period (.). The parser gets confused. I renamed the fields in the attached.

2) Calculating elapsed time. I am not sure what unit of elapsed time you are trying to calculate given you have the enter events on the StartTask and EndTask set to initialize and format the current time to the second. As a result, I added a calculate script on the TotalTask to generate the elapsed time in seconds. I included the commented calculations for minutes and seconds as well.

// topmostSubform.Page1.TotalTask::calculate - (FormCalc, client)

if (HasValue(StartTask) and HasValue(StopTask)) then

     var Interval = Time2Num(StopTask.formattedValue, "HH:MM:SS A") - Time2Num(StartTask.formattedValue, "HH:MM:SS A")

     // elapsed time in seconds

     $.rawValue = Interval/1000

     // elapsed time in minutes

     // $.rawValue = Interval/(1000 * 60)

     // elapsed time in hours

     // $.rawValue = Interval/(1000 * 60 * 60)

endif

3) Button to pencil tool. I have no idea.
4) You can add documents as attachments in Acrobat using the paper clip in the navigation panel.
Steve

Avatar

Level 1

Thank you for the helpful hints, and the coding. I knew that the Mileage would be easy... As far as the time goes it did not work, striaght from the edited document, I added the times in both locations, and was not able to get a number calculated, is there a key stroke or something that I am missing?

Avatar

Correct answer by
Former Community Member

Hmmm. Try removing the formatted value option in the Time2Num functions.

var Interval = Time2Num(StopTask) - Time2Num(StartTask)

Steve

Avatar

Level 1

PERFECT!!!!!! Oh this is sucfh a life saver!!!! Thank you for all of your help.

Avatar

Level 1

Ok, I have one more question. I got a request to have the Total Time to be rounded to the nearest 1/4 hour. I have tried to get that information, but no luck, do you have any ideas?

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----