Join the Team Forms community

Updated last month

Allowing Manual Override of Calculated Value is causing the field to not update on change

At a glance
The community member was having an issue with a calculated value not updating when the "Allow Manual Override of Calculated Value" option was checked. The calculated value was a string that included data from multiple other fields. When the option was unchecked, the calculation worked as expected, but when the option was checked, the field remained blank and no redraw was done. The community members discussed a few workarounds, such as using the "On Change" setting to update the value of another field, and preventing the logic from running when the form is reopened. Ultimately, the issue was caused by a bug with the "Allow Manual Override" feature, which has now been fixed in the latest release of Team Forms.

I am having issue with the calculated value not updating upon change.

I am using the calculated value feature as such:

value = data.textfield + 'text' + moment(data.date) + 'text'.

Redraw on any change as this is pulling from multiple other fields.

This works as expected when 'Allow Manual Override of Calculated Value' is unchecked. However, as soon as I check that option, the calculation does not work as intended. No redraw is being done when box is checked.

The field remains blank when other fields are updated. Not even the string of prepopulated text appears in box. When testing in build mode, it appears that no changes are being made to this field as soon as the manual override option is selected. If I start with box unchecked and make changes in preview, it works. If I go back into build and change that setting, the text field is now editable, but the data remains unchanged from state it was in when the override box was checked, even if the fields data is being pulled from have changed.

No other changes made to form. The allowing of manual override on this text field is the only variable changed.

What I am wanting to do is create a title for the form that uses a standard format, but in certain cases, allow the user to override the default to better clarify the presented information.

Marked as solution

Hi @Ryan ,

The cause of your issue was a bug with the "Allow manual override" feature. This has now been fixed in the latest release of Team Forms.

View full solution
E
R
A
3 comments·2 replies

Hi Ryan,


It looks like there may be some issue with the "Allow Manual Override of Calculate Value" option as i'm also able to re-produce this issue on my end. I've gone ahead and logged an internal issue with the development team to investigate and will provide any updates here.

As a temporary work around you could use an alternative method of setting the text field using the on Change setting (available in the logic tab). The onChange is like a calculated value but instead of a component setting its own value it can be used to set a different component's value any time its own value changes. Here's some steps to try:

  1. Remove the calculated value from your text field

  2. Go to the component setting for the textfield you previously referenced in your calculation. Navigate to Logic Tab > On Change

  3. Enter in the following JavaScript to update another components value. Note that you will need to adapt the code below for your specific form

Updated

JavaScript
if(flags.modified){
	instance.root.getComponent('textField1').setValue(data.textField + 'text' + moment() + 'text')
}


Follow up question. Is there a way to prevent this logic from running when a form is reopened?

We use a two step form (submission and approval) and when form is opened via edit url, the logic runs (I assume upon opening) and overrides any changes the submitting user made to the default format.

To clarify, the source fields are not being changed by the approver, however the logic runs and the destination text field is changed back from user updated value edited before submission to default format driven by the code.

There is no logic on the submit or approve buttons that impact the source or destination fields.

Hi Ryan,

To add to Erins response, you can prevent the logic from re-running when a form is initially opened by checking the variable flags.modified . This variable will be settrue only when there is a user triggered change.


So to improve Erins response you could use:

JavaScript
if(flags.modified){
	instance.root.getComponent('textField1').setValue(data.textField + 'text' + moment() + 'text')
}


Ultimately the easiest option will be to use the "Allow manual override" when that is fixed. However, for now this should work well :)

Hi Ryan,

Thats a tricky one. I think until such time as fix is available for the "allow manual override" option is implemented a better option to resolve your underlying issue is to instead do the following:

  1. Add an "Alternative title" question

  2. Within your title template dynamically set the title to the default or the alternative title programmatically

Hi @Ryan ,

The cause of your issue was a bug with the "Allow manual override" feature. This has now been fixed in the latest release of Team Forms.