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

Question

Question

Prevent empty lookup results from overwriting filled fields

asked on August 12

Is there a way to prevent a lookup rule from overwriting data with empty strings? I have several lookup rules that try to provide defaults for fields further down the form. If a user overwrites one of those defaulted fields, then jumps back up and changes a field that triggers one of those lookups, the later field is overwritten by the lookup, even if it didn't find a match.

I'm looking for a way to either prevent the lookup from replacing values with an empty string, or to use javascript to disable a particular lookup.

[v 10.2.1]

0 0

Answer

SELECTED ANSWER
replied on August 13

Hi Scott,

It's kind of difficult to prevent lookup when result is empty (that would require modifying original Forms code and lookup is too complicated to update), but there is an easy way to prevent lookup updating a field. Use script like this:

$('#q2 input').focusout(function(){
    $(this).attr('vo','k');
  });

q2 is the lookup rule target field. On focus out of the field, it will change the "vo" attribute to "k" which means keep current value. Then lookup result won't overwrite this field value.

1 0
replied on August 14

Thanks! Is there documentation anywhere that explains the magic of "attr('vo','k')"? In this case, I seem to get the same behavior by just setting the attr as when wrapping it in the focusout function.

0 0
replied on August 14

There is no documentation: this is not some kind of public interface Forms provided, and it is not guaranteed that this function will work the same way in future release. You might think of it as a "trick" to make lookup rule work in the expected way at this moment.

The "focusout" is used so that if the field is not manually updated, the lookup rule still work.

0 0

Replies

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

Sign in to reply to this post.