Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Can't Override Calculated Fields

Avatar

Former Community Member

Hello,

I have a form that has fields in which are calculated, they are set though to calculated allow override.  When we type in a value that's not calculated, it pops up the warning message, allows you to change the value, but the second you click off of it, it reverts back to the original value.

Any ideas on how to fix this?

6 Replies

Avatar

Former Community Member

What type of object is it?

How are you calculating the object value?

Do you initialize the object value in the initialize event?

Avatar

Former Community Member

Hello

What type of object is it?

A text box

How are you calculating the object value?

On the text box's calculate event I have an if then statement

Do you initialize the object value in the initialize event?

No, because I never knew I had to do this.

I guess it's important to know, this was working fine in my form, some how it's not working anymore.

Thanks

Joe

I've attached a PDF which has an isolated example of the issue.

Avatar

Former Community Member

Joe,

You have come across some behaviour for the 'Calculated - User Can Override' Value property that you (and almost everyother user) would question. While I cannot explain it, I will share my observations.

For a TextField with a Value proprerty of 'Calculated - User Can Override', Designer expects a script to be attached to the Calculate event. While you have attached script to the Calculate event, it appears that Designer is VERY picky about what the script does. It appears that a variable assignment is expected regardless of the target variable.

If I add 'var foo = "bar";' to the Calculate event of TextField, Designer behaves as you would expect.

If I add 'xfa.host.messageBox("foo"bar");' to the Calculate event of TextField, Designer does NOT behave as you would expect. The TextField rawValue is set to '1'.

Additionaly, if you do not have any script in the Calculate event, Designer will reset the Value to 'User Entered - Optional'.

My solution is attached. I added a comment ("//') to the Calculate event to preserve 'Calculated - User Can Override' and then drove the population of the TextField from the CheckBox.

Steve

Avatar

Former Community Member

Wow, that's a lot of code to correct though.  I have a hundred and fifty of these fields in the real form that I already coded. I'll do it if I have to, but the oddest thing is if you create a new pdf, and copy and paste the check box and text box, it behaves as expected.

also what does || mean in the code is it "or"?

Thanks

Avatar

Former Community Member

After HOURS of trying to recreate this problem I finally can reproduce it, however I still can't figure out the solution.

The code that was given, works, but would complicate to the nth degree the rolling calculations in my form.

I swear this is a glitch, but maybe I don't understand the model.  If I take that field (It is posted as an attachment in a previous post) and create a new PDF and paste it into it, the field behaves as expected allowing the "calculated user override" to occur.  However if I make one change to the form properties, and change "Preserve Scripting Changes to Form When Saved:" to Automatically this causes the calculated fields to not be able to override.

The really odd thing is, if I change it back to manual, this does not fix the problem.

Is this a glitch or does anyone have any insight into it?

Thanks