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

Question

Question

How to kick off a lookup after copying a field value to another field?

asked on July 13, 2015

We have a Forms process that has a field called Applicant ID. The user enters the ID number and then it is submitted. The next step kicks off a workflow that does a lookup into a web API using the Applicant ID to find the match. The XML is then parsed out to create tokens and then they are inserted into a MSSQL database table. Once the workflow completes, the next step in the process is a user task. The user task already has the Applicant ID from the initial form submission, so it does not perform the lookup (see this post: https://answers.laserfiche.com/questions/80329/Lookup-Not-Working-at-User-Task).

I have tried to copy the value of applicant ID and put it into another field to kick off the lookup, but that did not work either (See this post for the code: https://answers.laserfiche.com/questions/80393/How-to-copy-value-of-field-1-to-field-2).

So the question is, is there a way to kick off a lookup when the value of a field already exists, or when a value has been copied from one field to another?

0 0

Answer

SELECTED ANSWER
replied on July 14, 2015

In the above reply, for the "field id" I mean the id at the input element level so your code should be:

$('.applicantNumberLookup input').val($('.applicantNumber input').val());  
$("#q5 input").attr("vo", "e");
$(".applicantNumberLookup input").change();

To explain more, if you look at the page elements using developer tools, for a field it would look like this:

There are two ids for a field, one at <li> level is in format of "q1", while the other at <input> level is in format of "Field1". The custom CSS name is also at <li> level. And if you want to do values operation for a field, you will need to perform on the <input> level.

2 0
replied on July 15, 2015

Rui, that worked! Thank you very much for all of your help and Alex's help. This is going to make a our process in Forms a lot smoother for the end user.

0 0
replied on September 3, 2015

For some reason today this stopped working. The value of the .applicantNumber input field gets copied to the .applicantNumberLookup inout field, but the lookup does not get performed.

Nothing has changed in the code or the process itself, so I'm not sure why it stopped. Any ideas?

0 0
replied on September 3, 2015

Never mind. We discovered the problem.

0 0
replied on June 6, 2017

What was the problem?

0 0

Replies

replied on July 13, 2015

First, to trigger a lookup rule with only one field as match field, you can use JavaScript like this (Field1 is match field id):

$("#Field1").change();

Second, for the lookup rule in user task, I want to revise that the lookup rule will be performed on user task as long as it's not read-only, but the rule won't fill the target fields when the target fields have been used in other forms and already have filled value when approve the task. I guess this is why lookup won't fill fields in your process.

At last, if you really want to use fields in multiple forms and trigger lookup rule to overwrite existing value, here is the way (Field1 is match field id while Field2 is target field id): 

$("#Field2").attr("vo", "e");
$("#Field1").change();

 

1 0
replied on July 14, 2015

Rui, thank you for taking the time to look at this for me. I tried to follow your instructions, but I apparently am not understanding something correctly as it is not working. Below is a screenshot of part of the form in question when it reaches the user task along with the CSS classes next to the two applicant number fields.

I added the following jQuery to the form:

$('.applicantNumberLookup input').val($('.applicantNumber input').val());  
$("#q5").attr("vo", "e");
 $(".applicantNumberLookup").change();

#q5 is the id of the Last Name field. When I pull the form up in the user task in question, a lookup is not performed on the last name field. Am I understanding your code wrong?

0 0
replied on July 14, 2015

The Javascript should just be

$('.applicantNumberLookup input').val($('.applicantNumber input').val());  
$('.applicantNumberLookup input').change();
0 0
replied on July 14, 2015

Alex, I tried the JavaScript you posted. It does copy the value from the .applicantNumber to the .applicantNumberLookup, but it does not kick off a lookup on the .applicantNumberLookup field.

0 0
replied on July 14, 2015 Show version history

try for the trigger,

 

$('.applicantNumberLookup input').trigger('change');

That usually does the trick for me when I run into situations like this.

0 0
replied on July 14, 2015

I'm not able to recreate the issue. Here's a test business process I've created. Note that this process uses two different forms: a starting form and a lookup form (for the user task).

Lookup Table

Starting Form

Lookup Form definition/js

Lookup form's lookup rule

Lookup form user task approval

In your process, are you using a single form for everything or are you using two different forms for starting the submission and then for the user task (as I am above). Also, can you confirm that the lookup rule itself is configured to run based on the correct field in the correct form?

0 0
replied on July 14, 2015

I am using two different forms that share the Application Number field. The lookup rule itself is configured to run based on the correct field.

I decided to do this on a test form as well to see if I could get it to work and I get the same result of the number being copied from one field to another, but the lookup never kicks off.

I am running Forms version 9.2.1.1069. Is that the same version you are running?

0 0
replied on July 14, 2015

Yes, I'm using Forms 9.2.1.1069.

For your testing, are you still incorporating the Workflow aspect where it takes the applicant number, gets the corresponding values, and then inserts it into a database table, which is then used by the lookup in the second form during the user task?

If so, is your business process configured to wait until the workflow finishes before proceeding?

What if you bypass that step and just test with a database table that already has the lookup values? The business process would just have a start event followed by the user task and then an end. I want to see if removing the workflow step and just using a lookup with the data already present would work or if that still results in an issue where the lookup isn't getting run automatically.

0 0
replied on July 14, 2015

The original process does still utilize the workflow to populate the database and waits for the workflow to finish before moving to the user task.

The test form I created however does not. It is a simple form like yours, but it does a database lookup into the same database table for the information.

I just noticed that there was a duplicate application number in the database because of our testing, so I deleted it. Now looking at the form in the CSS and JavaScript tab, it does perform the lookup correctly. However, it is still not performing the lookup at the user task itself.

0 0
replied on July 14, 2015

Can you open another case with your reseller for this matter? We'd want to review the test business process you're using. If you could also provide a small database backup with the table and some dummy values to test with, that would be helpful.

0 0
replied on July 19, 2017

I ran into a similar issue recently where I set the data but it did not kickoff the lookup. I finally realized that the field the lookup was referring to was marked as "Read-Only". I tried removing that option and it started working.

It kind of makes sense since Lookup Rules are based on matching values that users put into fields to lookup values for other fields. I just wish the "change" event would fire the lookup regardless, especially if the field is being populated by a different lookup and you don't want the user to change the value that is populated. I ended up having to mark the field as css "hidden" to keep users from messing with the value for now.

I wish I had realized the link between read-only and lookups sooner, but at least it's working.

1 0
replied on December 7, 2020

Has anyone gotten this to work with Forms 10.4.5?

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

Sign in to reply to this post.