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

Custom Calculation Script in Acrobat

New Here ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

Hiya all! I am currently creating a form in Acrobat that includes calculation. The form looks like this:

 

1 Box Sqft          Total Sqft          Boxes Required          Total Box Sqft

21.74                   90                       4                                   (Boxes Required) * (1 Box Sqft)

 

Using simplified field notation, I have set Boxes Required based on the total sqft entered, which is (Total Sqft) / (1 Box Sqft). However, I encounter a problem when entering the formula above for Total Box Sqft. Upon keying in the formula, the answer would just be following Total Sqft. So for example, if the Total Sqft was 100, Total Box Sqft would also be 100 despite of the (Boxes Required) * (1 Box Sqft) formula which rightfully should be 86.96. 

 

I suppose that this has to do with the fact that Boxes Required already has an existing formula which interferes with a new formula set in Total Boxes Sqft. Is there a method to solve this issue? 

 

Thank you in advance for all your help! 

 

TOPICS
General troubleshooting , How to , JavaScript , PDF forms

Views

907

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Aug 08, 2022 Aug 08, 2022

I think I understand... Add the following as the custom Validation code of "Boxes Required":

 

event.value = Math.floor(event.value);

Votes

Translate

Translate
Community Expert ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

You need to fix the fields calculation order. You can do that in Prepare Form mode, via the More button.

Set "Total Box Sqft" to be lower in the list (ie. calculate after) "Total Sqft".

Votes

Translate

Translate

Report

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
New Here ,
Aug 08, 2022 Aug 08, 2022

Copy link to clipboard

Copied

Hi try67, thanks for your prompt assistance! I have checked the Field Calculation order and "Total Box Sqft" is set lowest in the list. Still getting the same values as "Total Sqft" unfortunately.

Votes

Translate

Translate

Report

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 08, 2022 Aug 08, 2022

Copy link to clipboard

Copied

Odd. Can you share the file with us?

Votes

Translate

Translate

Report

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
New Here ,
Aug 08, 2022 Aug 08, 2022

Copy link to clipboard

Copied

Most definitely, thank you! Please find attached the file for your kind reference. 

Votes

Translate

Translate

Report

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 08, 2022 Aug 08, 2022

Copy link to clipboard

Copied

I don't understand the issue... You've set "Boxes Required" to be "Total Sqft"/"1 Box Sqft" and "Order Quantity" as "1 Box Sqft" * "Boxes Required", so of course the result will be the same as "Total Sqft". Am I missing something here? The only issue is you've set Boxes Required to not show any decimals, so the value it displays does not correspond to its actual value, which is what's used in the calculation. Is that what you're referring to?

Votes

Translate

Translate

Report

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 08, 2022 Aug 08, 2022

Copy link to clipboard

Copied

I think I understand... Add the following as the custom Validation code of "Boxes Required":

 

event.value = Math.floor(event.value);

Votes

Translate

Translate

Report

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
New Here ,
Aug 08, 2022 Aug 08, 2022

Copy link to clipboard

Copied

LATEST

Yes, you're correct! My initial issue which I didn't realise was setting "Boxes Required" not to show decimals which in turn displayed the wrong value. The custom validation code works perfectly to resolve that issue. I appreciate your time and assistance once again, try67!

Votes

Translate

Translate

Report

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