Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Adobe PDF Forms - Calculate Simplified Field Notation

Community Beginner ,
Aug 24, 2023 Aug 24, 2023

I've read multiple items on this and all seams so simple, but once I try it doesn't work:

 

I want a profit/loss column. Subtract from Sale Amt from Purchase Amt to give it a positive or negative number.

 

In the simplified field notation: for profit/loss column

SaleAmt - PurchaseAmt

 

I get nothing in the field. What am I doing wrong?

TOPICS
How to , PDF forms
589
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2023 Aug 24, 2023

SFN (Simplified Field Notation) doesn't work with field names that have space in them.

You need to escape space character with backslash like this:

Precio\ Compra - Precio\ Venta

Also, your fields are named:

Precio\ CompraRow1 - Precio\ VentaRow1

Instead of using SFN in every field, you can use this as 'Custom calculation script' use it in only one field (any text field is good) it will calculate for all fields:

for( var i=1; i<=33; i++){
 var a = Number(this.getField("Precio CompraRow"+i).valueAsString);
 var b = Number(this.getField("Precio VentaRow"+i).valueAsString);

 if(a !== 0 && b !== 0)
  this.getField("Ganancia  PerdidaRow"+i).value = a-b;
 else
 this.getField("Ganancia  PerdidaRow"+i).value = 0;}

Here is your file with script added:

https://drive.google.com/file/d/1R3smEJsCVv48Xp28dNi2W45oASLwvbGb/view?usp=sharing 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 26, 2023 Aug 26, 2023

Nesa, thank you so much, but the formula is backwards. I need to show the sale price - the purchase price. That way it properly shows my profit / loss. The current formula is showing the purchase price vs the sale price giving me the opposite answer, when it should be a positive number vs a negative number, unless I actuall had a loss. How can I correct that i the formula?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 26, 2023 Aug 26, 2023
LATEST

I used the calculation order you had in your file (Precio Compra - Precio Venta).

If the calculation should be opposite, in the script, just change 'a-b' to 'b-a'.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines