Refresh Calculated Value form field by JavaScript.

  • 28 November 2017
  • 2 replies
  • 60 views

Badge +3

Hi all,

we have a requirement to force a calculated form field to refresh. It has a variable of ErrorCount. It is not connected to any SharePoint list column. 

We need to refresh the field this way as the calculated form field uses the lookup run-time function to return how many items are in a particular list, and give the total amount of items, using below formula:

count(lookup("ErrorList","Reference",Reference,"ID",true))


Whilst the form is open the list - that the calculated field returns the count from - gets updated - another item is added to it. When this happens we post a function called callback to the form.

Inside this function we need to update the calculated form field to show the new list total/ item count.

The function callback is successfully called, as we have confirmed with an alert, but the calculated form field is not  being refreshed, updated.

Inside our callback function we have tried:

function callback() {

alert('function called OK');

NWF$('#' + ErrorCount).trigger('blur');

NWF$('#' + ErrorCount).trigger('change');

}

Any idea on how to get the calculated form value field to recalculate /update?


2 replies

Badge +2

Below is the code you can use to refresh the calculated column

NWF.FormFiller.Functions.ProcessOnChange(NWF$("#" + txt_count);

client id of control : NWF$("#" + txt_count)

refer: Force refresh the nintex form using javascript 

Badge +3

I just wanted to add to this since I was running into a similar issue. I was setting the value of a control inside a repeating control and needed it to update the rule on each instance of a control inside the repeater.

 

Here is what ended up working for me (replace control_inside_repeater to whatever you set the CSS Class of your control to).

NWF$('.control_inside_repeater').each(function(control){
    NWF$(this).find('input').blur();
    });

The part that had me stuck for awhile was the need to do the find('input') rather than just trying to blur NWF$(this).

 

I also ended up needing to wrap that in a 2 second setTimeout function to allow all of the values to be set before it tried to retrigger the form rules.

Reply