Highlighted

Fields Visible Dependent on Date Field

Community Beginner ,
Sep 30, 2020

Copy link to clipboard

Copied

Hello,

I have tried to find a solutiuon by searching but haven't had much success so here it goes:

 

I have a payment request summary document that has 25 payment request rows. Each pay request row has a Date Field, then a Change Order amount Field, Austed Contract Amount, % Complete, Total Amount Earned, and other read only fields.

 

I want to make it so none of the fields for a payment request are displayed unless the associated date field is populated.

 

The problem is that the Adjusted Contract Amount is the sum of the Original Contract Amount plus the  Change Order Amount up to the 25th payment request. So, for each Adjusted Contract Amount the math is adding the Original Contract Amount + the number Change Order Fields. So, once an entry is made for payment request #1, the adjusted contract amount will populate all the way down to the 25th payment request. 

 

I'd like to have it so that none of the fields will display unless a date for a specific payment request is entered, and then only the rows associated with that payment request will be shown.

 

I have attached a copy of the pdf in question. I'm grateful for any help that can be shared. Thank you.

TOPICS
How to, PDF forms

Views

125

Likes

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

Fields Visible Dependent on Date Field

Community Beginner ,
Sep 30, 2020

Copy link to clipboard

Copied

Hello,

I have tried to find a solutiuon by searching but haven't had much success so here it goes:

 

I have a payment request summary document that has 25 payment request rows. Each pay request row has a Date Field, then a Change Order amount Field, Austed Contract Amount, % Complete, Total Amount Earned, and other read only fields.

 

I want to make it so none of the fields for a payment request are displayed unless the associated date field is populated.

 

The problem is that the Adjusted Contract Amount is the sum of the Original Contract Amount plus the  Change Order Amount up to the 25th payment request. So, for each Adjusted Contract Amount the math is adding the Original Contract Amount + the number Change Order Fields. So, once an entry is made for payment request #1, the adjusted contract amount will populate all the way down to the 25th payment request. 

 

I'd like to have it so that none of the fields will display unless a date for a specific payment request is entered, and then only the rows associated with that payment request will be shown.

 

I have attached a copy of the pdf in question. I'm grateful for any help that can be shared. Thank you.

TOPICS
How to, PDF forms

Views

126

Likes

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
Sep 30, 2020 0
Adobe Community Professional ,
Sep 30, 2020

Copy link to clipboard

Copied

This doable.   First, see this article on hiding and showing form fields. 

https://www.pdfscripting.com/public/Hiding-and-Showing-Form-Fields.cfm

 

Next, the ability to show/hide only the fields on a row depends on field naming. And it looks like your form follows a suitable pattern. 

To do this, use the validate script on the date field. If the field has content,then extract the row prefix and use it to build the names of the other fields in the row.

For example:

 

var bMakeVisible = (event.value != "");

var cPrefix = event.targetName.split("_").shift(); 

 

this.getField(cPrefix + "_co_amt").visible = bMakeVisible;

 

 

Likes

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
Reply
Loading...
Sep 30, 2020 0
Engaged ,
Sep 30, 2020

Copy link to clipboard

Copied

You can use this code as Custom calculation script of date field:

this.getField("pr1_co_amt").display=event.value==""?display.hidden:display.visible
this.getField("pr1_adjusted_amt").display=event.value==""?display.hidden:display.visible
this.getField("pr1_percent").display=event.value==""?display.hidden:display.visible
this.getField("pr1_amount_earned").display=event.value==""?display.hidden:display.visible;

This is just example if you have more fields in row add them to code, also you need to add code to every date field and change names accordingly.

Likes

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
Reply
Loading...
Sep 30, 2020 0
Adobe Community Professional ,
Sep 30, 2020

Copy link to clipboard

Copied

A calculation script is a really bad idea. Calculations are run every time any field on the form is changed. Since there are several , this calculation will severly slow the form. The script is also written for the specific row. Which means that it will need to be manually edited for each  field in the table.  Not only is this inefficient for entering and maintaining the script, but it creates many opportunities for human error.  Do not use this technique. 

Likes

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
Reply
Loading...
Sep 30, 2020 0
Community Beginner ,
Sep 30, 2020

Copy link to clipboard

Copied

Thanks Thom and Nesa, I appreciate the help!

 

Thom, I'm not sure if I understood you correctly, but this is what I entered for the first date field as a validation script:

 

var bMakeVisible = (event.value != "");
var cPrefix = event.targetName.split("_").shift();
 
this.getField(cPrefix + "_co_amt").visible = bMakeVisible;
this.getField(cPrefix + "_adjusted_amt").visible = bMakeVisible;
this.getField(cPrefix + "_percent").visible = bMakeVisible;
this.getField(cPrefix + "_amount_earned").visible = bMakeVisible;
this.getField(cPrefix + "_total_payable").visible = bMakeVisible;
this.getField(cPrefix + "_prev_paid").visible = bMakeVisible;
this.getField(cPrefix + "_amount_due").visible = bMakeVisible;
this.getField(cPrefix + "_enc_balance").visible = bMakeVisible;

 

This doesn't work when I applied it. What am I missing here? Thank you again for your help.

Likes

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
Reply
Loading...
Sep 30, 2020 0
Adobe Community Professional ,
Sep 30, 2020

Copy link to clipboard

Copied

Excellent take on the code. However, it's my mistake, working on too many different platforms at the same time. The correct property is "hidden" not visible. Also, it is more correct to use the newer "display" property. 

 

var bMakeVisible = (event.value != "");
var cPrefix = event.targetName.split("_").shift();
 
this.getField(cPrefix + "_co_amt").display= bMakeVisible?display.visible:display.hidden;
this.getField(cPrefix + "_adjusted_amt").display= bMakeVisible?display.visible:display.hidden;
this.getField(cPrefix + "_percent").display= bMakeVisible?display.visible:display.hidden;
this.getField(cPrefix + "_amount_earned").display= bMakeVisible?display.visible:display.hidden;
this.getField(cPrefix + "_total_payable").display= bMakeVisible?display.visible:display.hidden;
this.getField(cPrefix + "_prev_paid").display= bMakeVisible?display.visible:display.hidden;
this.getField(cPrefix + "_amount_due").display= bMakeVisible?display.visible:display.hidden;
this.getField(cPrefix + "_enc_balance").display= bMakeVisible?display.visible:display.hidden;

 

 

The next step in improving this code is to turn it into a document level fuction, so the code is only in one location.  You can read an article on this here:

https://www.pdfscripting.com/public/Document-Level-Scripts.cfm

 

Likes

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
Reply
Loading...
Sep 30, 2020 0
Community Beginner ,
Oct 07, 2020

Copy link to clipboard

Copied

Thom,

 

Sorry for the delayed response. I will make an effort to try and get this to work on my own and if I run into problems I may hit you up here in the near future. Thanks again for your time, it is very appreciated.

Likes

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
Reply
Loading...
Oct 07, 2020 1