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

Question

Question

Triggering a Lookup Field Query with a Collection Field

asked on September 16, 2020

Hi all,

 

I've got a Lookup Field entry that, in the When clause, contains a field from a collection (i.e. EmployeeID).  It's set to populate a form field (i.e. SomeOtherField) outside of the collection when the collection field (EmployeeID) is entered.  The lookup runs when I change EmployeeID, but it never populates SomeOtherField.  I know the lookup is running because I'm trapping it in the Javascript when the lookup completes.  I also know that the EmployeeID value I'm entering matches the corresponding value in the queried table.  Of course, triggering the exact same lookup using a field outside of the collection works fine.  Is this a bug, is it not possible to match a collection field value to a queried table column in a Lookup Field?

 

0 0

Replies

replied on September 16, 2020

Hi Eric,

Does your collection allow for a range of sets or do you have a fixed number of sets?

0 0
replied on September 16, 2020

Hi Jacob,

It uses "Range of sets" with min=1 and max=12.

 

 

Eric

0 0
replied on September 16, 2020

I can see how having a range of sets will cause problems. In your lookup rule, you're specifying one field in your collection (EmployeeID), but that field could appear 12 times with 12 different values, depending on how many sets you add (if I'm understanding you correctly). So, Forms won't know which EmployeeID you want in order to fill the field outside the collection with the corresponding data.

That said, I can't get it to work if I use a fixed number of sets (1), either. I can't seem to find anything in Laserfiche documentation regarding using data from a collection to fill something outside the collection. I'm guessing you could get this to work using some custom Javascript, but from my experience and my inability to find anything anywhere about this specific case, I'm not sure it's something you can do by simply configuring a lookup rule. Hope I'm wrong, though.

0 0
replied on September 16, 2020

Okay, makes sense.  Yeah, was trying to avoid using Javascript.  

0 0
replied on September 18, 2020

Update: I worked this out by putting "SomeOtherField" into the collection.  The lookupcomplete event handler passes in the number of the row in the collection that triggered the lookup (I wrote a function to parse the number out and used it to detect the value of "SomeOtherField" in the collection row that triggered the lookup.):  

$(document).on('lookupcomplete', function (event) {
      var CollectionRowNumber = GetRowNumberFromEventTriggerID(event.triggerId);

 var LookedUpValue = $('.MyCollectionClass .kx-repeatable > div:nth-child(' + CollectionRowNumber + ') .SomeOtherFieldClass input').val();

});
 

So, the Lookup Field entry populates MyCollection.SomeOtherField with the looked up value (from the query).

 

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

Sign in to reply to this post.