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

Question

Question

Forms 10.4 Collection & calculated field per row / default value

asked on August 15, 2022

Hello,

I have a form with a collection within it, layed out in columns.

The read only fields have been populated from a previous form submission, and now I want to make the fields on the right (Payable Distance, Payable Time) have a default value based on data/ calculations for the ROW . 

I have highlighted the issue I am facing - it is totalling (via concatenation??!!) the figures for all the rows. 

What I would like to see is:


 

The payable time is in minutes and calculated from the hours & minutes fields.

I am struggling with this - should it be a calculated field? or a default value?.
How do I reference the field - just for the row. My calculated fields currently look like:

 

Payable Distance: (concatenating all rows)

=Mileage_Claim_1.Distance      <- This needs to refer to just the current row.

 

Payable Time: (not returning anything!!!)

=MULT(Mileage_Claim_1.Hours,60)+(Mileage_Claim_1.Minutes) <- This needs to refer to just the current row AND do the calculation as hoped!)

 

I had hoped / expected to be able to do this without javascript.

Any advice / suggestions would be welcomed.

Thank you.

0 0

Replies

replied on August 15, 2022

Glad you found it. One thing to point out is that fields with calculations don't really work as a default. It looks editable, but won't save what you put in there, at least not consistently. If you want to do a default, I'd recommend putting the calculation on the first form, then setting that as the default value for the field on this form.

1 0
replied on August 15, 2022

Found the answer in a previous post.

https://answers.laserfiche.com/questions/197487/Concatenate-field-entries-for-current-row-of-a-table#197489

 

It's all about the INDEX and ROW!!

 

0 0
replied on August 15, 2022

Hi Richard,

As Pieter mentioned, calculations do not make good "default" values because they actively change and can overwrite user inputs.

0 0
replied on August 15, 2022

A few things to consider:

  1. You'll want your values to be numeric if you're performing any mathematical functions because strings and numbers behave differently (i.e., 2+2=4 but "2"+"2"="22")
  2. You can't use Calculations if you want the fields to be editable because changes could trigger the calculation to just be reapplied and wipe out user edits
  3. I don't think you can use indexing in default values, and even if you could, you wouldn't be able to do any calculations in a default value

 

Your best option is probably to have your fields be present on the initial form, but on that form, have them be Hidden (set to Save values) and read only.

Then you can set those values in the previous submission without the user messing with them, and they will be pre-populated on your next task.

To reference the current row, you need to use INDEX and ROW because table and collection variables are arrays and will return all  values unless you specify

For example

=INDEX(Table.Columns,ROW())

INDEX(array, item) tells it to retrieve a specific value from the array, and you have to put a separate index function around each column variable.

ROW() tells it to use the current row of the table/collection as the index

But, as I said before, you need to do this on the FIRST form, because if you do it on the one where the fields are editable the calculations could overwrite whatever the user enters.

0 0
replied on August 15, 2022

Good points, Jason.

Yes, I think you're right, my "default" value option won't work since it's in a table. So, Jason's recommendation (if you don't mind me paraphrasing) is basically to run the calculation on the initial form, then make that field editable without the calculation on the later form. That would make the calculated value show up as a "default".

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

Sign in to reply to this post.