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

Question

Question

JavaScript to fill hidden field if other javascript is triggered?

asked on August 15, 2022

Can a person have JavaScript in a form process that, if triggered, another piece of JavaScript will make a radio button choice of Yes be activated?  This way, a Laserfiche Report could have a column that could be sorted to find all the instances where the JS was triggered?

I have JS that will highlight the last row in a table if someone adds a new row to a lookup filled table.  We now need to be able to quickly find all the instances and document those cases where extra rows were manually added.  Having JS within the original JS is the only way I can think of, but I'm not good enough with JS to attempt this on my own.  I know we can't backtrack, but moving forward we now know we want this ability for auditing purposes.

Can anyone help?  Note, there is more than one table in the form that could have extra rows added to tables.

0 0

Replies

replied on August 15, 2022

You can select radio buttons with JavaScript of course, but it's hard to say exactly what you should do without knowing your existing code, however, you also need to consider how it should behave if the user removes the row they added before submitting.

Say for example they add a row, which triggers your code, highlights the row, and sets the value of your yes/no option, but then they remove the row and the value is still set to Yes.

 

Another option would be to skip custom JavaScript entirely and use a combination of a hidden field inside the collection, and a hidden field outside of the collection with a formula.

  1. Add the new Read Only column/field to your table/collection
  2. Set it to Hidden and Save the value
  3. Use the lookup to populate the field from a column that will always have a value in the source like an id; this way it will be blank for user-added rows/items but never for a row added via lookup
  4. Add another Read Only field outside of the collection
  5. Set it to Hidden and Save the value
  6. Under Advanced, set the formula =COUNTIF(Table.Column,"=")

 

That formula will return a count of the rows where the hidden column is empty effectively giving you a count of how many rows were added by the user, and it will update automatically so you don't have to worry about them adding and then removing rows.

 

If you make the second field a number, you could then filter the report on any instance where that value is greater than 0 and see exactly how many rows were added.

 

If you only care about Yes/No, then change the formula to 

=IF(COUNTIF(Table.Column,"=")>0,"Yes","No")

Alternatively you could just go with the true/false value and skip the IF function

=COUNTIF(Table.Column,"=")>0

2 0
replied on August 17, 2022

Hmm... I like your suggestion, Jason!  Thanks!  I won't be able to try it out today, but definitely later this week I will be setting this up to see if we can make it work for us!  Thanks, again!

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

Sign in to reply to this post.