You are viewing limited content. For full access, please sign in.

Question

Question

Field Calculations / Adjusting Tables - JavaScript HELP!

asked on September 20, 2017

Hey everyone,

 

Here is what I am looking to accomplish.

 

We're in the process of making our entire Time Card process digital via LF Forms. It has been a crazy month to say the least to get this up and running... but we're getting close. Basically, a user submits the form online. It calculates, row by row, their weekly totals. Works great.

Upon submission, it eventually gets to Payroll, who then needs to be able to adjust those rows. We decided the easiest way to implement this would be through two additional columns in a copy Form - one for a calculation (either + or - X), and one for the adjusted total as a result. I imagine through JavaScript, this can be accomplished, but I have no idea how to make that happen.

Can someone assist? What I'd like for Payroll to be able to do is, in the Calc field, somehow distinguish to either add or subtract X value from the Total field, to then equate to the Adjusted Total field. For each row. Attached is the Form example, and my JavaScript thus far, if it helps, which only serves to calculate each row total so far.

 

Adjusted Totals.JPG
Java.JPG
Java.JPG (44.82 KB)
0 0

Answer

SELECTED ANSWER
replied on September 20, 2017

It sounds like you should be able to do this with Functions (the advanced settings for the field) instead of JavaScript. For example, the Total column for a single row would be like

SUM(INDEX(table.column1,ROW()),INDEX(table.column2,ROW()),INDEX(table.column3,ROW()))

The total for a column would be

SUM(table.column1)

And the "adjusted" total would be

SUM(INDEX(table.totalColumn,ROW()),INDEX(table.calcColumn,ROW()))

Just replace the "table.column" with the appropriate variable from the ">" drop down list in the functions menu.

If they put 1.0 in CALC it will add 1, if they put -1.0 it will subtract 1. The only requirement is that all of the fields be "Number" rather than "Single Line"

1 0
replied on September 20, 2017

Worked like a charm! You're the man, thanks!

0 0

Replies

replied on September 20, 2017

If it would be easier... instead of that "Calc" field... I could create two fields instead, one for "Add X value" and one for "Subtract X value." Again, per row.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.