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

Question

Question

Lookup Rule not working with Java Script.

asked on March 7, 2018

I’m working on a form where our customer is adding the number of people living in a household into a table. I am then using a java script to calculate the amount of rows that are added into that table and having the amount of rows inserted into a field in a collection. This piece is working fine.

The real problem that I’m having is that when that java script is “engaged”, the lookup rule that I have in place is not working. The lookup rule is pulling information from a SQL table that has the number of people in the house and the guideline numbers.  It seems that the lookup rule is unable to read the number that being placed in “number in household” field in the collection that is being calculated from table 1 as explained above.  In turn it will not populate the “guideline” field number in the collection.

If I take out the java script and keep the lookup rule in place and enter a number in the “number in household” field manually, the lookup rule will bring up the correct guideline number.

I’d really like this process to be automatic if possible. If anyone has any ideas, I’d appreciate it.

0 0

Replies

replied on March 7, 2018 Show version history

Hi James

Your coding skills are likely stronger than mine, but what I think what you are experiencing is as you are using Javascript to set the value in the field, I believe that Forms doesn't realize the value has changed which is why it's not running the Lookup.

You may have to manually trigger the field the lookup is based on to indicate that it has changed

ie:   $("#Field103").trigger('change');

or refresh the field that will be receiving the lookup data in conjunction to the above

with one or the other of examples below

$("#q104 input").attr("vo", "e");
$("#q104 textarea").attr("vo", "e");

 

You may also have to use this in conjunction with the Field Change trigger

$("#q104 input").attr("vo", "e");
$("#q104 textarea").attr("vo", "e");
$("#Field103").trigger('change');

As you lookup values are in a table it may require variations on this

 

Hope this helps

5 0
replied on June 6, 2018

This is an old thread, but I just wanted to give props to you. This was the final brick I needed to complete my task! Was going insane trying to figure out how to refresh the DOM without refreshing the page.

1 0
replied on March 8, 2018

Perfect! Thanks so much for your time. 

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

Sign in to reply to this post.