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

How to display blank on computed field instead of zero?

Contributor ,
Feb 27, 2023 Feb 27, 2023

Good day!

 

I have a computed field that I made "Read Only" because the value that will be displayed in this field should show the result of a mathematical formula. Currently, when you open the PDF file, what it displayed is $0.00 even if I have not inputted anything on the two operants.

 

Example:

 

F01001b = blank (no value entered yet)

F01001c = blank (no value entered yet)

F01001d = computed field with formula F01001b*F01001c

 

I wish that field F01001d should display blank and not $0.00 when no value is entered in F01001b and F01001c.

 

Thank you again for your effort in coming up with a solution to this request.

 

 

 

TOPICS
How to , PDF forms
5.5K
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
1 ACCEPTED SOLUTION
Community Expert ,
Feb 28, 2023 Feb 28, 2023

As validation script of that field, use this:

if(event.value == 0)event.value = "";

View solution in original post

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 ,
Feb 28, 2023 Feb 28, 2023

As validation script of that field, use this:

if(event.value == 0)event.value = "";

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
Contributor ,
Mar 01, 2023 Mar 01, 2023

Hi Nesa,

 

Thank you for always being there to help me with my issue. Very much appreciated.

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 ,
Mar 08, 2023 Mar 08, 2023

This did not work for me. It actually produced a 0 once the calculation was run?

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 ,
Mar 08, 2023 Mar 08, 2023

I need it to be blank unless a calculation is run in the associated fields.

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 ,
Mar 08, 2023 Mar 08, 2023

The script did not produce 0 your calculation did.

You got answer on your second post for your calculation, if you use that script and this one correctly you will get desired result.

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 ,
Mar 09, 2023 Mar 09, 2023

It should not have been 0 with what I entered in the other fields it should have been a number greater than zero. But, I'm trying it again today and it still shows a negative value in the field without entering in any data instead of remaining blank. I'm still new to this so I appreciate the support! Here's the script:

event.value = Number(this.getField("Remaining Balance 1").valueAsString) / Number(this.getField("Divide by 2").valueAsString);

 

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 ,
Mar 09, 2023 Mar 09, 2023

Try this script:

var f1 = Number(this.getField("Remaining Balance 1").valueAsString);
var f2 = Number(this.getField("Divide by 2").valueAsString);
if(f1&&f2)
event.value = f1/f2;
else
event.value = "";

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 ,
Mar 09, 2023 Mar 09, 2023

That did not work either 😞 Sigh...

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 ,
Mar 09, 2023 Mar 09, 2023

Where did you put the script?

Did you check that field names are correct?

Share your file, so we can see what is going on.

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 ,
Mar 20, 2023 Mar 20, 2023

Sorry, I was out of the office for a bit. I tried putting this in the custom calculation script under validate tab and then also tried putting it in the calculate custom calculation script.

var f1 = Number(this.getField("Remaining Balance 1").valueAsString);
var f2 = Number(this.getField("Divide by 2").valueAsString);
if(f1&&f2)
event.value = f1/f2;
else
event.value = "";

 

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 ,
Mar 20, 2023 Mar 20, 2023
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 ,
Mar 20, 2023 Mar 20, 2023
LATEST

"Divide by 2" is not a field, so you can remove that one field that you tried to add and just divide "Remaining balance" by 2:

var RB1 = Number(this.getField("Remaining Balance 1").valueAsString);
if(RB1)
event.value = RB1/2;
else
event.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