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

Discussion

Discussion

Forms Lookup, Preview does not match Production, data returned from SQL is incorrect

posted on August 20, 2018

I have a basic one dimensional lookup configured in Forms.

When I preview the form, I get the expected results.

If I assign this form to a user and run the process, the results change, even though the database is static. A value "Marcos" appears.

I can view the same form in Preview and as Task and get different results on the same workstation. In neither case is the lookup failing, there is only one hard coded value in the drop down "Loading from database". The system is adding "Marcos" as a value. Why?

 

0 0
replied on August 23, 2018

It ended up being something very obscure. I had the lookup fields in a collection. I also had javascript configured to delete all rows of the collection be clicking on the X button when the form is loaded.

The button to remove collection rows looks like this 

Manually clicking the X button for a collection's rows doesn't explicitly disable lookup rules but the javascript was written like this:

// Get all X buttons from my collection
var cusid_ele = document.getElementsByClassName('cf-collection-delete'); 

// Click them all
for (var i = 0; i < cusid_ele.length; ++i) {
   cusid_ele[i].click();  
}

Seems really straight forward and I expected this would be the same as the user manually clicking them.

However as soon as you add a second row to a collection, two of these X buttons appear where there was none to begin with. The first is a hidden one that is always there.

If you try to click both, one will disappear before you have a chance, preventing deletion of the first row.

Javascript does not have this limitation though, it successfully clicks both too fast for the system to remove the other. Somehow, if you click both X buttons in the collection at the same time, it disables ALL lookups across the entire form, replacing the return values with whatever the last lookup values were in cache before clicking both buttons. Even lookup rules outside of the collection were effected in this way.

In preview, javascript was even finding a way to click the hidden X button for the first row, but the lookup problem does not happen unless you click both the first X button and the second X button at the same exact time, which requires 2 rows of data, which was only present in the task. This is why it never broke in preview.

The workaround is to never click the hidden X button in the collection, which is always the first one. And simply clear the values of the first row instead.

  
  $('.clear select').each(function() {
    
   $(this).val('').change();
    
  });
  
  $('.clear textarea').val('');
  
var cusid_ele = document.getElementsByClassName('cf-collection-delete');
for (var i = 0; i < cusid_ele.length; ++i) {

  if(i>0) // Never click the first row's X button
   cusid_ele[i].click();  

}

 

0 0
replied on August 21, 2018

Check your dropdown field and see if it is appending anything to the lookup results displayed in the dropdown. Are these two different Forms withing the same Business Process? If yes, then on the faulty one, remove the dropdown field and add it again.

0 0
replied on August 22, 2018

Not sure how to configure appended data. The drop down is working in preview, why would it be any different using the preview screen vs opening the form from the inbox? I am only working with one Form, I can make a small change to the form, open preview and open from the inbox, and see the change, verifying that I am not looking at an alternative form.

I am planning to jump on a var webinar soon to get remote assistance.

0 0
replied on August 20, 2018

Chad,

 

What results do you get from a new query in SQL Management Studio for that Table/View with a Task value of 'Review reports'?  Is there any record with a StaffMember = 'Marcos'?

0 0
replied on August 22, 2018

Hi Cliff

I get the same results as I get when previewing the form. There is a Staff Member named Marcos but not with any Task named "Review Reports". The lookup works in Preview, but not when opening the Form from tasks. I am looking at the same exact form.

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

Sign in to reply to this post.