Copy link to clipboard
Copied
I have set up a budget form and at the end I'm subtracting one manually entered field from another field with manually entered data. This does nothing at all in Acrobat XI Pro. I got nothing, nada, no result. In Acrobat DC Pro and DC Reader I get a result with like 8 decimal places (.00000000) and I can't see how to limit this to no decimal places. Now when I reopen in Acrobat XI, I am getting the same result as I got in DC, but only after a crash and restart of Acrobat.
I've even renamed the fields so they are super simple to enter... my equation "Barclay_Last-Barclay"
This should be a simple calculation -- have tried the "-" on above the keyboard and the "-" minus sign from the numpad. That makes no difference. I have tried other calculations using *, for example, and they work fine.
Obviously something wrong here, but I don't think it's what I'm doing. Is it because I have XI Pro and DC on the same Windows 7 machine? Or ???
Copy link to clipboard
Copied
The "." is a special character and denotes a decimal place in a numeric value. It needs to be "Escaped" to indicate to the behind the scenes JavaScript that the "." is to be treated as a character and not a decimal point. Try:
Text4\.0\.6\.0 - Barclay
Copy link to clipboard
Copied
Does it not work for all entered values or just certain ones? If just certain ones, can you give some examples?
Copy link to clipboard
Copied
Thanks for your interest. My simple notation formula is this
Text4.0.6.0 - Barclay
Tried formatting all 3 fields (the calculation field, Barclay and Text4.0.6.0) as numerical, that did not help. All data in these fields is positive, not negative. These are the only Simple Notation calculations I'm using and none of them work. Other calculations where value is Sum, work.
Copy link to clipboard
Copied
That's a different field name than you showed before. If you have punctuation like that in the field name, you'll have to escape the characters like this:
Text4\.0\.6\.0 - Barclay
It's best to use only alphanumeric characters (plus underscore) for field names so you don't have to bother with this.
Copy link to clipboard
Copied
Really. This is the name that Acrobat automatically gives the fields when you create them using Create Multiple Copies. Will try this and see if it helps.
Copy link to clipboard
Copied
That worked! Changed all field names from 4.0.1... to Barclay_B, Barclay_C, etc.
Thank you so much.
Copy link to clipboard
Copied
Most users that use the "create multiple copies" also tend to write custom JavaScript calculations for all sorts of reasons. Many users have found that the simplified field notation and "field is the _____ of the following fields" tend to fail on complex or lengthy forms. They also may write document level functions to process rows of data by calculating the field names and perform column functions. The use of document level functions can also improve performance of the forms since the code is only syntax checked once and tokenized once.
Copy link to clipboard
Copied
Really. This is the name that Acrobat automatically gives the fields when you create them using Create Multiple Copies. Will try this and see if it helps.
I should have said: If you're going to use the Simplified Field Notation option for calculations, it's best to use only alphanumeric characters (plus underscore) for field names so you don' have to bother with this.
Copy link to clipboard
Copied
Well thank you again.
I would think that Adobe would not create autogenerated names that violate the rules for "Simple" Notation. I Googled this problem, and didn't find any comments or warnings regarding the use of Special Characters in filenames... I don't do Javascript (other than copying someone else's code) but I've been using multiple copies since at least Acrobat 6. Calculations are another thing, I've never really done much with them, thought I would try a simple budget form. I work with forms all the time, just haven't had a need to do calculations.
You were a big help!
Copy link to clipboard
Copied
You should be able to control the displayed number of decimal places using the format tab and setting the format to "Number" and the number of decimal places to ")". Note this will round the result of the calculation.
You may need to have a space before and after the minus sign. Simplified field notation uses spaces to parse the entry into field names, values and operands. The "-" can indicate subtraction or a negative value. The space after the "-" indicated one wants to subtract the value and not have it as a negative value.
Copy link to clipboard
Copied
Thanks,
I should have been able to figure out the decimal place. Geez. Sometimes the brain is just not helping.
I have included a space before and after but still my Simple Notation calculation is not working.
Here is what I have written:
Text4.0.6.0 - Barclay
Tried formatting those fields as numerical, that did not help.
Copy link to clipboard
Copied
The "." is a special character and denotes a decimal place in a numeric value. It needs to be "Escaped" to indicate to the behind the scenes JavaScript that the "." is to be treated as a character and not a decimal point. Try:
Text4\.0\.6\.0 - Barclay
Copy link to clipboard
Copied
I may have a solution for you if you need to rename lots of field names.
My problem was a slightly different in that I wanted to change a field name with a "period" to an "underscore", since Adobe seems to struggle to do 'simplified field notation' calculations with fields that were named with a period, but not with an underscore.
so if i tried to do box.1 - box.2, nothing happened, but when renamed to box_1 and box_2, now the formula box_1 - box_2 in 'simplified field notation' works fine.
For some reason when you create multiple text boxes (such as when you right click on one field and then do 'create multiple copies..') it renames each one with a period, so if your first field is named "box", and you create 2 copies, it will rename them "box.1" and "box.2".
On windows, ctrl+J to open the javascript console, clear the console and paste this into the console, (the box one at the bottom). Do ctrl+A to select all of the script that you just pasted, and then ctrl+enter to execute it. It should rename the fields to "box_1" and "box_2" and so on. Hope this can help someone.
Script:
// Loop backwards so that removal doesn't affect the loop indices
for (var i = this.numFields - 1; i >= 0; i--) {
var origName = this.getNthFieldName(i);
if (origName.indexOf('.') !== -1) {
var newName = origName.replace(/\./g, '_'); // Replace all periods with underscores
// Get the original field
var origField = this.getField(origName);
if (!origField) continue; // safety check
// Create a new field with the same type, page, and rectangle
// Note: You may need to adjust parameters depending on your field type.
var newField = this.addField(newName, origField.type, origField.page, origField.rect);
// Copy basic properties. You may want to copy additional properties as needed.
newField.value = origField.value;
newField.defaultValue = origField.defaultValue;
newField.textSize = origField.textSize;
newField.multiline = origField.multiline;
newField.alignment = origField.alignment;
newField.readonly = origField.readonly;
// Copy any additional properties if needed:
// newField.font = origField.font; etc.
// Remove the original field
this.removeField(origName);
console.println("Renamed field '" + origName + "' to '" + newName + "'");
}
}