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

Question

Question

Values from getFieldValues blank when executed on a table variable within an onLookupDone event

asked on June 26, 2024 Show version history

Hey all,

I have a table that on load, will load up ~2000 results from a lookup rule using the "as new row" option.

Now from this table, I need to remove a very specific number of results which I am hoping to use JavaScript for.

Using the following code, and I get the correct number of values, but the values themselves all return empty.

LFForm.onLookupDone(async () => {
  const rows = LFForm.getFieldValues({ fieldId:6 })
  console.log(rows);
}, { lookupRuleId: 1 })

It seems like the onLookupDone is firing before all the values have actually finished loading into the table, because if I try adding an artificial delay before doing the getFieldValues, it loads all the values successfully.

LFForm.onLookupDone(async function() {
  await new Promise((res) => setTimeout(res, 1000))
  const rows = LFForm.getFieldValues({ fieldId:6 })
  console.log(rows);
}, { lookupRuleId: 1 })

Any advice on how I should proceed from here?

Thanks

0 0

Replies

replied on June 27, 2024

Right now, onLookupDone fires when the lookup rule has been executed and data has been received, not necessarily when it has filled in the fields from the lookup rule. Instead, I would use the onFieldChange event on your field { fieldId:6 } to get the values any time it changes. If you want to get the values for every column of the table, listen to the change event of the last field filled by the lookup rule.

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

Sign in to reply to this post.