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

Calcluate based on year

Avatar

Level 2

Hi,

Looking for help on calcluating something in a form.

I have a table with three columns (Things, Year Purchased, Cost).  The Year Purchased column has drop down list with 2010 and 2011 in it.   Under the table I have two numeric fields named 2010 and 2011.  When a person selects a Year Purchased and then puts a cost to it (ex Thing = socks, Year Purchased = 2010, Cost $5.00) I want the year 2010 numeric field to show the $5.00.  If 2011 is selected I want the cost to go into the 2011 numeric field and finally, as more costs are inputted for either year, I want the numeric fields to keep adding them and show the sum.

Unfortunately the table can't be laid out any different than what is described.  I have an example but I can't figure out how to attach it...I'm surprised I was able to turn the computer on this afternoon

Any help would be much appreciated.

Andrew

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Is this what you are after Andrew?

Untitled.png

Steve

View solution in original post

4 Replies

Avatar

Former Community Member

Is this what you are after Andrew?

Untitled.png

See the calculate events on cost, _2010 and _2011.

Steve

Avatar

Level 2

Hi Steve,

It is very close.  The cost field needs to be inputed by the user but what you have done for the rest of it is exactly what I am looking for.  The only problem is that it won't work for me.  I suspect the problem is on line 2 of the script but I don't know enough to say for sure.  On my form I only have one table row and a button that allows the user to add more rows if needed.  In line 2 of the script on your form it looks as though it is saying that i is equal to 0 or less than or equal to 4 (the total number of rows in your form).  Do you think this is the problem?

Thanks for your help

Andrew

Avatar

Correct answer by
Former Community Member

Is this what you are after Andrew?

Untitled.png

Steve

Avatar

Level 2

Yes this is exactly what I was looking for.  Thanks again Steve.

Andrew

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] ----