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

Question

Question

Lookups not triggering on Form load

asked on September 22, 2015 Show version history

Hi,

I have a Form that contains a lookup rule based on the InstanceID of the Form that loads up. Unfortunately, the lookup rule does not automatically run when the form loads up - even though the parent value (InstanceID in this case) is present.

The only way to populate the child fields is to clear out the InstanceID field, click off it, then retype the value.

Is there any way to "push" or re-trigger the lookup on Form load?

The instanceID field is made up of a hard written digit, {/dataset/_bp_process_id} & {/dataset/_instance_id} and the form is not the form used during submission.

 

--Update--

It might be worth noting that the instanceID field is populated before values are entered into the database table.

0 0

Replies

replied on May 12, 2017 Show version history

I see this is a fairly old post but I ran into this with the exact same scenario. It came down to a time issue IMO.  Put a delay in and it works like a charm.

This code below fixed it (field has a css class of followupnumber:

 

$(document).ready(function() {
  var delayMillis = 1000; //1 second
setTimeout(function() {
  $(".followupnumber").on('click',function(){    
  $(".followupnumber input").change();
});
  $(".followupnumber").trigger('click');
}, delayMillis);
});

 

4 0
replied on June 20, 2018

Thank you, Shaun!

0 0
replied on August 12, 2020

I'm on Forms 10.4.4, and the trigger. ('change') in user tasks was not working for me, but in the form preview everything was fine.

With this script from Shaun I got it to work in user tasks.

 

Thanks!

0 0
replied on September 23, 2015

I tried to reproduce what you're trying to do. I created a field (id=q100) that triggers a lookup to be done and populates several other fields when a value is entered. I set a default value for that field.

When the form loads, nothing happens (as expected). However, if I add this line at the top of my javascript:

  $('#q100 input').val().change();

when the form loads, it executes this command, which is like physically changing the value in the field. The lookup runs and populates the other fields as expected.

If that isn't working for you, is it possible the database doesn't have a key matching the value in the field? Or maybe there's no data in the column used to populate Field B (maybe the data isn't written to the database prior to the form loading)? Or maybe you have something overwriting the value in Field B after the lookup populates it?

I use the "alert" method when I know values are changing. I put it at the places where the value changes so that I can see what the value is at each step before the rest of the code runs. (I'm sure there are better ways to troubleshoot, but I'm not a javascript expert.) You might try that to see if Field B ever gets set.

 

1 0
replied on September 28, 2015

The jquery example you provided returns an error in the console (F12) but using:

$("#q100 input").change();

...works for repopulating the lookup - so thanks for that! :)

Problem I have now is getting it to trigger automatically on form load, as I can only get this working manually (for example "when user clicks on field").

$("#q47").on('click',function(){	
  alert("value changed");
  $("#q47 input").change();
});
  $("#q47").trigger('click');

The above works, but the trigger does not automatically update :(

Thank you for your comments !

0 0
replied on September 28, 2015

So, if I understand correctly, the instance id is filled in on one field in a form. Then on the next form in the process, the instance id field (q47) inherits the value from the previous form.

Your lookup needs to run when the second form is loaded based on the value in field q47 to fill in a second field. Right now, that's not happening unless a user manually enters the instance id or changes field q47 in some way.

And, if you just put $('#q47 input').val().change(); at the top of your javascript in the second form (not as part of an event or in an if statement, just on its own), it still doesn't trigger a database lookup?

I'm not sure why because it seems to trigger the lookup on my forms. Maybe someone else can weigh in on this?

0 0
replied on September 22, 2015 Show version history

Hi there,

When you lookup criteria is field A, result fill to field B. Does field B already have some submitted value in previous steps?

Did you use the {/dataset/_instance_id} as default value of field A?

 

0 0
replied on September 23, 2015 Show version history

Hi Abby,

Field A is populated with the instanceID during the first user task (with no value in Field B), then data is added to SQL (which creates a value for Field B), then another user task is created so therefore Field A still has a value but Field B should now be populated also.

Yes I am using instance ID as the default, to be more accurate I'm using: 

"100{/dataset/_bp_process_id}{/dataset/_instance_id}" as Field A's default value.

0 0
replied on September 23, 2015

Hi there, if Field B exist in the first user task with no value. It still take precedence over the lookup result. Because user intentionally set it to be blank. We want to show the next user what is the user set value instead of directly overwrite with lookup when page load. If Field B doesn't exist in the first user task and any previous form submission, and exist in the second user task. it'll have lookup value on the field when page loads. 

0 0
replied on January 20, 2016

Hi,

I am having the same issue mentioned above,Is there any solution to resolve this?

0 0
replied on September 22, 2015

Hi, Dominic.

Try $('#<fieldID> input').change(); at the beginning of your javascript. (You may have to put a '.val()' before the ".change()", but I'd try that first. If your lookups trigger based on that field, this should notify them that a change occurred in that field.

0 0
replied on September 23, 2015

Hi Sheila,

No luck with this unfortunately :(

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

Sign in to reply to this post.