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

Insert formula in Form

New Here ,
Oct 11, 2023 Oct 11, 2023

Copy link to clipboard

Copied

Hi everyone,

I'm trying to develop a form in Adobe PRO (as a beginner) and I need a little help to solve the following tasks:
1 - how to write this formula "Field1*Field2+if(Field3=<5;Field4;Field5)*Field6+Field7" to obtain the Calculated Result. With 3 separate helper Fields(hidden in Form) i have achieved the result, my try is to obtain direct in Filed calculation, without helper fields.
 
2 - how to change text color in a text field when certain events have place:

"IF(Field8>Calculated Field; text color RED;text color Black)"

here it will be a bonus for me if I will know how to change and backround of a field on whish, not only the text, but anyway, dont count how small hint I will receive, it will be more than I have now.

 

Thanks in advance for your time and efforts,

Cristian

 

TOPICS
How to , PDF forms

Views

721

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 , Oct 11, 2023 Oct 11, 2023

- It should go under the latter, Custom Calculation Script.

- I made a small mistake in the code. It's fixed now.

Change:

v3=<5

To:

v3<=5

Votes

Translate

Translate
Community Expert ,
Oct 11, 2023 Oct 11, 2023

Copy link to clipboard

Copied

For 1:

 

var v1 = Number(this.getField("Field1").valueAsString);
var v2 = Number(this.getField("Field2").valueAsString);
var v3 = Number(this.getField("Field3").valueAsString);
var v4 = Number(this.getField("Field4").valueAsString);
var v5 = Number(this.getField("Field5").valueAsString);
var v6 = Number(this.getField("Field6").valueAsString);
var v7 = Number(this.getField("Field7").valueAsString);

event.value = v1*v2+(v3<=5 ? v4 : v5)*v6+v7;

 

For 2:

 

var v8 = Number(this.getField("Field8").valueAsString);
if (v8>event.value) {
	event.target.textColor = color.red;
	event.target.fillColor = color.black;
} else {
	event.target.textColor = color.black;
	event.target.fillColor = color.red;
}

 

 

PS. I moved your question to the Acrobat forum from the Reader forum.

 

Edit: mistake in code fixed

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 ,
Oct 11, 2023 Oct 11, 2023

Copy link to clipboard

Copied

Thank you very much for you answer, seems somehow easy....until I tried to put it into practice.

So, regarding first point, when I have tried to insert the script(adapted after my needs) in

Fiber32847772y9jh_1-1697047939913.png"Simplified field notation"  - is accepted, but no any generated value.

when I try to insert in "Custom calculation script", I receive next error and cannot pass over.

Fiber32847772y9jh_0-1697047843081.png

Clear, I missed the correct point or position to use, or form to introduct.

Moreover, I have 4 different Fields which need this Calculated Value in base of 4 different situation, then, I suppose is necessary and a clear definition of "event.value" for each of those 4 Fields, not only for first of them.

All those 4 Fields are like "Calculated Value" for each standard situation on which is reffering and have no connection with....

 

now I will refer on second point, about text/background color, where that task should occur when the value manually inserted in that field is over "Calculated value" for this specific Field, not the one on top. So, if I try to estimate how should be(with your script and my supposing) is like this:

 

var v1 = Number(this.getField("Case1").valueAsString);\\variabil, 1 for each 4 cases in a row
var v2 = Number(this.getField("Length").valueAsString);\\ fixed for all 4 cases in a row(96)
var v3 = Number(this.getField("-5").valueAsString);\\ fixed field for all
var v4 = Number(this.getField("+5").valueAsString);\\ fixed field for all
var v5 = Number(this.getField("Splice").valueAsString);\\ fixed for all 4 cases in a row(96)
var v6 = Number(this.getField("Field6").valueAsString);\\ fixed field for all
var v7 = event.value = v1*v2+(v2=<5 ? v3 : v4)*v5+v6*2;\\ 1 for each 4 cases in a row

\\ this means v7 is different on each Field from all 4*96 rows, IF value manually inserted in this field is > respective "Calculated Value" according his case THEN

var v8 = Number(this.getField("This Field").valueAsString);
if (v8>event.value) {
	event.target.textColor = color.red;
	event.target.fillColor = color.black;
} else {
	event.target.textColor = color.black;
	event.target.fillColor = color.red;
}

 

Clear, my pro point is not explaining in words, but maybe another visual try can be more helpfull to understand correct the needs.

So, simple:

- first point is refering only on 4 Fields which are calculated in fct of specific Fields(in red marked) , just for consulting the accepted limits, which can be changed without any influence in down part.

- second point is refering on blue marked area(where can be visible some values writen with red), those values being compared with his own calculation according same formula as point 1, but in function of his own Length and Splice(different from row to row)

Fiber32847772y9jh_3-1697053470426.png

In Excel was somehow easy to obtain the desired result, but with under 48h experience in Acrobat Pro and Java seems not so fast for me. I hope I was enough clear in my tentative to explain the problem, and I would like to thank you again for your time spend with this topic.

 

best regards,

 

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 ,
Oct 11, 2023 Oct 11, 2023

Copy link to clipboard

Copied

- It should go under the latter, Custom Calculation Script.

- I made a small mistake in the code. It's fixed now.

Change:

v3=<5

To:

v3<=5

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 ,
Oct 11, 2023 Oct 11, 2023

Copy link to clipboard

Copied

LATEST

This change works like a charm, and I have achieved and for second point to compile things for obtaining desired result. Thanks again many many times!

 

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