Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Overridable calculations...bug?

Avatar

Former Community Member
Has anyone been able to implement a field that is calculated, but can be

overridden? I have created a numeric field that calculates a value

based on two other fields. I then selected the field type to be

"Calculated - User Can Override". The calculations occur successfully,

however, if I attempt to override the calculated value, as soon as I

exit the field it replaces the typed-in value with the calculated value

again.



I have also trying experimenting with different values for the

'override' property on the Calculate object in the XML source, but

nothing seems to change the behavior. It doesn't appear to be behaving

the way the XFA Specification says it should.



Is this a bug? Is there any other way to allow overrides of calculations?



Justin
11 Replies

Avatar

Former Community Member
I can confirm that this is a bug. Actually, the bug manifests itself in a couple of different ways in Acrobat 7.0.7 or earlier:








  1. Dynamic PDF: Not only will the value specified by the user (the override) not be retained but the warning message (if specified) won't be displayed. The behaviour is simply to let the user type-in a value but then throw it away and run the calculation again without an warning.






  2. Static PDF: In this case, the warning message (if specified) is displayed and the user has the option to discard their change or proceed with the override but the specified value is discarded regardless of what they choose to do and the calculation is run again.







Fortunately, I can confirm now that this bug has been fixed for the next release of Acrobat.



Stefan

Adobe Systems

Avatar

Former Community Member
Okay, we just bought the Adobe Professional package to make forms that are calculated with user override--just to find out there's a bug? When is Adobe going to make a free patch for those of us who just spent $450 on the software?

Avatar

Former Community Member
This is certainly a very unfortunate situation.



If you purchased a maintenance plan with Acrobat Professional, then the upgrade to Acrobat 8.0 Professional -- which will include the fix -- would be free to you or your company. Otherwise, the next release of the Adobe Reader (8.0) should also have the fix and upgrading to that once it is released will be entirely free of charge.



Stefan

Adobe Systems

Avatar

Former Community Member
There is a way to hack around the issue.



Basically In this example I'm calculating the amount of tax (6% in Canada) into a field called tax. But if we want to override the tax we would edit the field by hand which would trigger a change event.



On the change event I set a hidden field's rawValue to 1. (I use adobehack as my field name in this example)



Then on the tax field's calculate event I check the adobehack field first to make sure it's value is not 1.



----- F.P1.tax::calculate - (JavaScript, client) ---------------------------------------------



//I check my hidden field to see if I should calculate or ignore.

if(F.P1.adobehack.rawValue!=1)

F.P1.subtotal.rawValue*0.06;



----- F.P1.tax::change - (JavaScript, client) ------------------------------------------------



//This sets the hidden field to 1 so I know it's been overwritten.

F.P1.adobehack.rawValue="1";



Tada! $30+ saved. Please mail me 50% of that cash. :)

Avatar

Former Community Member
Jon,



What Ricardo is suggesting is a workaround to the Acrobat 7.x bug where a field whose value is calculated yet overridable cannot, in fact, be overridden in the way XFA specifies that one should be able to do.



When you set a field's Value Type to "Calculated - User Can Override" (using the Value tab in the Object palette), that's supposed to define a field with a calculated value (via script) which the user can opt to override with a specific value that, once entered into the field, shouldn't change.



The problem is that while Acrobat 7.x lets you override the calculation by entering a number in the field, once you press Enter or click away to commit the override, it's completely ignored and subsequent calculations use the calculated value from the script instead of the value that was specified as the override.



Using Ricardo's workaround, you can achieve the desired functionality without having to wait for a bug fix in Acrobat 8.0. Essentially, Ricardo's workaround is using a hidden check box to determine whether the calculation has been overridden. When the user enters a value, it's considered an override and the check box's value is set to 1. Then, when calculations are run on the form, the field's calculation script first checks to see if the check box's value is 1. If it is, it just uses the value already entered into the field. Otherwise, it uses the default script.



Stefan

Adobe Systems



Learn how to
build intelligent forms using Adobe LiveCycle Designer.

Avatar

Level 4

This workaround works great, however, when I save the form and go back into it, the override didn't stay.  Is there a script for that or is that the way it goes....I'm using LC Designer 7.1.  thanks

Avatar

Level 3

Similarly I have a add remove instance on my form.  So here is my calculation field

Sum(F.P1.CalcGroup.CalcArea.ItemSet[*].Cost)

However when an instance is removed the calculation isn't automatically updated, it holds the previous value.  How can I make the field recalculate on change?

My override statement is below

----- F.P1.CheckBox1::change - (JavaScript, client) ------------------------------------------------

CheckBox1.rawValue = "1";

----- F.P1.subtotal::calculate - (JavaScript, client) ----------------------------------------------

if (CheckBox1.rawValue!=1)
F.P1.overflowTrailer.Amount.rawValue = Sum(F.P1.CalcGroup.CalcArea.ItemSet[*].Cost);

----- F.P1.subtotal::change - (JavaScript, client) -------------------------------------------------

CheckBox1.rawValue = "1";

Avatar

Former Community Member

In order to have a calculated field reflect a removed instance (or added instance), add this line in the code that removes or adds the instance:

xfa.form.recalculate(1);

The following Adobe forum entry was also useful to me to figure out how to calculate a field from numerous (unknown number of) instances of subform fields:  http://forums.adobe.com/message/2064154#2064154

Avatar

Level 4

This didn't help me, however, I figured out how to fix my problem.

In my Override.pdf sample, I removed the change event script CheckBox1.rawValue = "1"; from the subtotal field and added it to the Amount field. This allowed me to override my Amount field and save the change.