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

Question

Question

Automatic Autofill for Collections

asked on August 30, 2016

I have a simple form that is performing a lookup on two values to populate a dropdown field on the form.  This dropdown field and lookup fields are all contained in a collection.  I added the following JavaScript to execute autofill when the lookup condition is changed:

 

$(document).ready(function () {
  function autofill() {
  $('.autofill').trigger('click');
}
  $('.IBMIC').change(autofill);
});

 

This works in updating the dropdown field in the first in the first part, but if the user adds additional sections to the collection, all subsequent sections do not update the lookup field.  I have attached a screenshot of the form, Lookup Rules, and JavaScript.  Any help is greatly appreciated.

 

 

Autofill_Collection Issue.png
0 0

Answer

SELECTED ANSWER
replied on August 31, 2016 Show version history

This is because when you add a row, the "change" event is not registered to the ".name" field of the new row.

You can add code like this to register the event:

  $('.cf-collection-append').click(function(){
    $('.IBMIC').change(autofill);
  });

 

2 0
replied on August 31, 2016

Thank you Rui.  That did the trick.

0 0
replied on September 19, 2018

Any suggestions on how this can be modified for multiple autofills in the same collection?

0 0

Replies

You are not allowed to reply in this post.
replied on November 29, 2017

Following code work in Forms 10.1:

$(document).ready(function () {

   function autofill() {
    $('.autofill').trigger('click');
  }   
 $('.lookupCondition').change(autofill);
});

$('.cf-collection-append').click(function(){  
  function autofill() {
    $('.autofill').trigger('click');
  } 
  $('.lookupCondition').change(autofill);
});

After upgrade to 10.2.1, only the first set in the collection is functioning - any further additions to the collection won't work. Can anybody point out the flaw? It was working in 10.1, so curious why it would stop now in 10.2.1. 

You are not allowed to follow up in this post.

Sign in to reply to this post.