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

Question

Question

Lookup Help: How to Display Hidden Field when Lookup Finds Multiple Results?

asked on August 29, 2014

We currently have a form that performs a lookup of an employee's information in our HR software. It does the initial lookup by the employee's email address. It then retrieves what's called a "supervisors namekey". Once the "supervisors namekey" is populated in a field it then does a second lookup using the namekey for a record and pulls that records "supervisors username" and "supervisors email address". We use those two fields to dynamically assign user tasks to supervisors. The namekey field is a hidden field since it is a little cryptic and if it is incorrect than the entire lookup does not work.

 

The Problem: We are discovering that some employees have more than one record and each with a different supervisor. So when the email address is looked up, it does not fill in the "Supervisors Namekey" field because one needs to be selected from the two available.

 

We need a way for these special end users to be able to select which supervisor it should go to. Since the namekey is not very useful, it would be best if they could select the actual supervisors name (which can be pulled from the same lookup) and then have it populate the "supervisors username" and "supervisors email address".

 

I'm not the best at jQuery, so any helpful solutions are welcomed.

0 0

Replies

replied on August 29, 2014 Show version history

So, ideally you want an additional field that allows the user to select one of the supervisor usernames that were filled in previously?

0 0
replied on August 29, 2014

We do want an additional field that allows a user to select one of the supervisor names, but currently for it to even lookup the supervisors name, the "supervisors namekey" has to be selected first.

0 0
replied on August 29, 2014

So you need to select a namekey before you get the supervisor name, but you want the namekey to display the supervisor name?

 

I have a hunch that you're using an Oracle data source, so I won't tell you that a stored procedure is the way to go here.

0 0
replied on August 29, 2014

Almost there. We do need to select a namekey before we get the supervisor name, but the supervisor name(s) can be displayed in their own field. I hope this is making sense.

0 0
replied on August 29, 2014 Show version history

Ok, so really you have a hidden field that you want to display if it contains multiple values? Is the namekey field a single line or a drop-down?

0 0
replied on August 29, 2014

I think we're on the same page now. The namekey field is a single line.

0 0
replied on August 29, 2014

If there's more than one value, they'll get placed in auto-suggestions for the single line field. You can detect that and make the field visible. Here's the basic idea:

 

$(document).ready(function() {
  //hide the namekey field
  //detect changes to the matched fields that you use to fill in the namekey 

   if ($('.nameKey datalist select option').length > 1) {
      $('.nameKey').show();
    }
});

 

0 0
replied on August 29, 2014

Thank you for the help with this. The first part should be great, but instead of showing them the namekey field,  I would like to populate a supervisor name field for them to select from so that it is more friendly. Is there a way to do a lookup of the namekeys that are returned to populate a supervisor name field?

0 0
replied on September 3, 2014 Show version history

Try this:

$(function () {
  $(document).ready(function() {
  //hide the namekey field
  //detect changes to the matched fields that you use to fill in the namekey 

   if ($('.nameKey datalist select option').length > 1) {
      $('.supervisor').show();
      $('.supervisor input').val($('.nameKey datalist select option:eq(1)').val());   // Sets the supervisor field to the second auto suggestion for the given field
    }
});
});

Should do the trick, assuming you meant that the supervisor field is marked with the CSS class name 'supervisor'

0 0
replied on September 3, 2014

Is there a way to get the supervisor name through a lookup without having to get the namekey? Ideally you'd match the employee name and return one or more supervisor names in a drop-down. In the case where there are multiple supervisors, that would probably be easier than getting the namekey and then trying to get the supervisor from the namekey.

0 0
replied on September 3, 2014

I can pull a supervisor name, but it is not unique. This is what is included in each record during a lookup:

So with each employee there is a column for Supervisor Name and Supervisor Namekey. I can only use the Namekey to look up the supervisor's information. I guess another way to do this would be to populate a drop-down list that shows the Supervisor Name and populates the data part with the Supervisor Namekey. Is that possible?

0 0
replied on September 3, 2014

That might not be possible (or at least might be pretty difficult without stored procedures). I thought maybe you'd populate the drop-down with the supervisor name, and then there would be another lookup on the supervisor name to pull in the namekey.

0 0
replied on September 3, 2014

That could be possible since each time a supervisor name is listed in that column, they would be identical.

replied on September 23, 2014

Is the option coming in Forms 9.2 to be able to populate a dropdown list from a lookup and also populate the data part of the dropdown list with a different value? For instance, If I perform a lookup in the database for a list of supervisors, but want to add the namekey as the data value.

0 0
replied on September 23, 2014

if you are using a SQL DB, you can kind of already do this. 

 

You would use a hidden field as the auto-suggestion field, and copy all the datalist options to the viewable field that is part of the lookup. You would then configure the lookup you want with the second table to be done through a stored procedure. The stored procedure will keep the field from giving it's own auto-suggested options. 

 

Not sure if you need to use the hidden field or not, but either way, you would set up the second lookup using a stored procedure and the first lookup would be done to the hidden field or to the first field so it gives the auto-suggestions.

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

Sign in to reply to this post.