Skip to main content
Participant
April 18, 2024
Question

Having balance hidden unless description is entered

  • April 18, 2024
  • 1 reply
  • 1263 views

 

Hi, 

 

I have taught myself a lot over the past few days. I taught myself how to run a custom validation script to make fields display if they equal $0.00. I also tuaght myself how to do simplified field notation to make one field subtract from another. 

My question is in relation to attached form.

For Text5 Field:

I curently have simplified field notation as Text3-Text4

I currently have custom validation script as if(event.value == 0)event.value = ""

 

If text is entered in description field then I always need $0.00 to show. I still want $0.00 calucation in Balance field to be hidden if no description text is entered. 

What do I entere in custom validation script to make this happen?

I hope this makes sense. 

THANK YOU IN ADVANCE

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
April 18, 2024

If you want to show/hide depending on value, you can use something like this as validate script of "Description" field:

this.getField("Balance").display = (event.value == "")? display.hidden : display.visible;

Participant
April 18, 2024

That did not work. My only concern is the balance field not showing zeros if a coloum is entirely blank however if there is something entered and Amount- Payment =$0.00 I still need that to show in balance field. Thank you

Nesa Nurani
Community Expert
Community Expert
April 18, 2024

In Balance Field always hide zeros unless text is inputed in description field

If you cannot do that

*unless any number is inputed in amount field.


I don't understand is 'Description' one field or a column of fields?

Let's assume it's a column of fields, since you already have a validate script to hide zeroes (and in this case you can't use validate script) we will hide balance field until there is at least one of the fields in a column with a value, use this as custom calculation script of any text field, and make sure "DODQFHXH" is correct name for balance field, in script first line remove "Text1","Text2"...etc and populate array with actual names of the fields from the column:

 

 

var fields = ["Text1", "Text2", "Text3"];
var checkField = false;

for (var i=0; i<fields.length; i++) {
var f = this.getField(fields[i]).valueAsString;
if (f !== "") {
checkField = true;
break;}}

this.getField("DODQFHXH").display = checkField ? display.visible : display.hidden;