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

Question

Question

Is there a way to use listen for table row deletions with the LFForm object?

asked on July 19

I'm creating a timesheet form for a client using the modern designer in Cloud and I have it almost fully functional except for one thing - I can't figure out a way to listen for table row deletions with JS. I referenced this Answers post to be able to detect field changes on all the actual fields in the table, but this doesn't work when a row is deleted. If anyone has come up with any code for this and would like to share, that would be greatly appreciated! Worst case I can instruct the client that if they delete a row then they need to make a change on another field in the table to get their hours totals to update, but that is not ideal and would get cumbersome for users, especially non-technical users.

 

Thanks in advance!

2 0

Answer

APPROVED ANSWER SELECTED ANSWER
replied on July 23

We definitely want to add this event. In the meantime, you can add a hidden/readonly field anywhere on your form with the formula

=COUNTIF(Table.Entry_s, "<>") + COUNTIF(Table.Entry_s, "=")

making sure to change the variable names to match any ONE column in your table or collection. Now you can use the following code. Update the first variable to be the field id of your new field and implement any business logic in the provided function

const rowCountFieldId = { fieldId: 72 };
let previousRowCount = LFForm.getFieldValues(rowCountFieldId);
const handleRowChange = ()  => {
    const newRowCount = LFForm.getFieldValues(rowCountFieldId);
    if (newRowCount < previousRowCount) {
        // do stuff when removed
    } else if (newRowCount > previousRowCount) {
        // do stuff when add row
    }
    previousRowCount = newRowCount;
}
LFForm.onFieldChange(handleRowChange, rowCountFieldId)

 

1 0
replied on August 2

Thanks! Just got a chance to test this and it works like a charm!

1 0

Replies

replied on July 22

Hi Shauna,

This is not supported yet, but we've added a backlog for it, id: 531802.

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

Sign in to reply to this post.