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

Question

Question

Getting look-ups to refresh on form load

asked on September 21, 2016 Show version history

We have built a multi-form process where in order to create a “report” for defective services/materials, however, a “roster” form needs to be filled out and submitted first. The “roster” form is also used to add to, delete from, or update a SQL table with the help of workflow on the backside.

Upon the “report” form load, a look-up to the SQL table where the “roster” information is stored executes and fills in the specified fields with the data stored in the table. The user completes and submits the form for review. So at this point we now have:

1) a complete & submitted “roster” form,

2) updated “roster” SQL table,

3) a complete & submitted “report” form, and

4) a new user task to review the “report” form and start approvals.

Roster form completed:

Report form completed:

 

The dilemma:

At this point, if you open the user task to review the report, you see the fields are all filled out – both the manually filled and pre-populated ones. If you:

1) close (‘X’ out, not Submit) the “report” form and

2) open the “roster” form associated with that “report” and

3) delete someone from the roster, and then Submit the form

 

Roster form updated: (Site Manager removed)

The workflow kicks off and it updates the “roster” SQL table.  Now, if you open the user task, I can see the JavaScript functions happening (because of show/hides, alerts, etc.), but the look-up does not refresh to match the updated SQL table, meaning it still populates with the original data the form was submitted with.

Report with original data still (look-up did not refresh - Site Mgr still populated, should be empty):

So far I have tried:

1) removed the read-only (set in JavaScript instead of ‘Field Rules’) attribute for the value used for look-up.

  • if you manually change the look-up value, the associated fields do change

2) adjusted the JavaScript to create a ‘change’ on the field hoping it would refresh the look-up tied to it.

$('#q140 input').trigger('change lookup');
  $('#q140 input').on('change lookup', function(){
    //alert('hit function');
  });
  • I have also tried clearing the field and repopulating, tried using element.change(), tried element.val().change(), tried copying to another field and using that variable for the look-up, but none of it works, in fact, using the element.val().change() combo completely crashes all of the Forms JavaScript for the form...

 

  • I know the functions are still running because on page load I get the alert

 

3) verified the look-ups are pointing to the correct SQL tables

 

So, does Forms run the created look-ups on submitted forms within an active process? Is there a way to get that look-up to kick off again? Any help would be greatly appreciated!

0 0

Answer

SELECTED ANSWER
replied on September 21, 2016 Show version history

On the user task of report form, the fields are all filled with values submitted in previous step, so the values are considered as carried value. On form load, carried value has a higher priority than lookup value, so the values won't be updated.

As for your script, the issue might be that your script runs before form load finishes, so form load script runs afterwards and keeps the fields with carried value.

There are some possible solutions:

1. Do not submit values on the lookup target fields (you need to remove those fields from the starting form), so there would be no carried value on user task form load, and lookup would fill the values;

2. Update your script with a setTimeout function so the trigger change function runs after form load, and it works as if you manually updated the lookup source field after form load; 

3. Update your script and change attributes "vo" to "e" on the target fields, so the values won't be treated as carried value, then trigger change on the lookup source field. The script should look like this:

$(document).ready(function() {
  $("#Field2").attr("vo", "e"); //the lookup target field
  $("#Field1").change();
})

 

1 0
replied on September 22, 2016

Thank you very much! Only needed to adjust the attr.() on the target field. Works awesome and does exactly what I wanted it to do now.

0 0
replied on April 30, 2017

Thanks Rui! This helped with a lookup table that's used in a parallel approval process.

In case it helps others, here's how to make a table re-do the lookup on a secondary user's task, for single line and multi-line input boxes.

$(".ReviewNotesTable input").attr("vo", "e");
$(".ReviewNotesTable textarea").attr("vo", "e");

0 0

Replies

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

Sign in to reply to this post.