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

Help: Custom Calculation Script

New Here ,
Jun 22, 2023 Jun 22, 2023

Hello, I'm sorry for the ignorance but I'm wracking my brain trying to figure this out. 

 

I have a document where I need the results from FormFieldA = FormFieldB only if FormFieldA is negative. If the number in FormFieldA is a positive number, I want FormFieldB to be 0. 

 

I hope that makes sense. 

 

TOPICS
How to , JavaScript , PDF , PDF forms
605
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 ,
Jun 22, 2023 Jun 22, 2023

Hi @Arianna306683197h1w ,

 

I think you can take care of that with a Custom Calculation Script or a Custom Validating Script executed in FormFieldA.

 

Maybe something like this:

 

(event.value >= 1) ? this.getField("FormFieldB").value = event.value : this.getField("FormFieldB").value = 0;

 

I have not tested the script myself but see if this works for you.

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 ,
Jun 22, 2023 Jun 22, 2023

This wouldn't check if for example value is 0.1, also it duplicates value if it's positive number and OP wanted to duplicate if it's negative number, so it would be better to check that value is less than 0:

(Number(event.value) < 0) ? this.getField("FormFieldB").value = event.value : this.getField("FormFieldB").value = 0;
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 ,
Jun 23, 2023 Jun 23, 2023
LATEST

Thank you as usual @Nesa Nurani for keeping an eye.

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