Execute javascript after form refresh?

  • 19 April 2017
  • 5 replies
  • 16 views

Badge +8

I can cause all of the calculated fields to refresh by calling the following function:

NWF.FormFiller.Functions.ProcessOnChangeEvents();

Is there any way to execute JavaScript after the refresh is complete?


5 replies

Userlevel 5
Badge +14

depends on what exactly you mean with 'form to be refreshed'...

there is a NWF.FormFiller.Events.RegisterAfterReady event handler which is invoked page/form is rendered, seePeople Picker Extensions - Nintex Forms . so you could place your code into it.

however, this handler do wait for asynchronous events, so some controls need not be populated with data yet when handler is invoked (typically lookups).

and there is, unfortunately, no event that would notify all the async events are done.

Badge +8

Thanks that is exactly what I want it to do.   I want my code to wait till the lookups are complete.

I am doing a userProfileLookupup

userProfileLookup(ctrlRequestedForID,"Manager")

I want to execute code only after the lookup is complete.

I tried

NWF.FormFiller.Functions.ProcessOnChangeEvents();
    
NWF.FormFiller.Events.RegisterAfterReady(function () {
            alert(NWF$("#" + JS_crtlCalcManager).val());});

But the value in the lookup field is blank or null for the alert but a value does display on the form.  So it looks like the code is running before the lookup is complete.   

Userlevel 5
Badge +14

the only way I'm aware of how to achieve that is to delay execution of your function by some timeout with setTimeout() javascript function. but it's just best guessed delay. in most cases it might work, but if for some reasons refresh is delayed your function might still be executed too soon.

Badge +8

I solved the issue by creating a function.   I placed the function in the calculated value foruma.

setDept(userProfileLookup(ctrFullLoginID,"SPS-Department"));

Userlevel 5
Badge +14

yeah.

but that's being evaluated during the refresh, not after it as you originally requested happy.png

Reply