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

Calculated Field - User Entry

Community Beginner ,
Nov 10, 2020 Nov 10, 2020

We user Acrobat with merge functions from a database. We concatenate "City, State Postal Code" with a Custom calculation script. In some records, we have a 'Bad Address Flag', which leaves these data fields empty in the merge process.


Our users would like to type in a City State Postal Code into the Text Field. But, because the field has a formula using 'event.value = ***", the manually entered information gets over-written when the user tabs out of the field.

 

My question is : is there are different command than 'event.value' which will allow the retention of the manually entered information ... or ... is there a way to wrap my custom calucation script in an IF THEN logic that will take the merge data if it is available, or retain the manual info, if merge info is not available? 

 

Thanks, 

Mike

TOPICS
How to , PDF forms
763
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 ,
Nov 10, 2020 Nov 10, 2020

There is, but it's tricky. The way to do it is to look at the source of the calculation (via event.source.name). If it's one of the fields whose values you're combining ("City", "State", etc.) then proceed with the calculation. If not, do nothing. This will allow the user to enter a custom value, and won't overwrite it the next time the value of another field is changed.

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 ,
Nov 10, 2020 Nov 10, 2020

Don't know your exact code but try something like this if you want manually enter when field is empty:

if(event.value == ""){

event.rc = false;}

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 ,
Dec 04, 2020 Dec 04, 2020
LATEST

Thank you ... it was the 'if' statement.

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 ,
Nov 10, 2020 Nov 10, 2020

There is, but it's tricky. The way to do it is to look at the source of the calculation (via event.source.name). If it's one of the fields whose values you're combining ("City", "State", etc.) then proceed with the calculation. If not, do nothing. This will allow the user to enter a custom value, and won't overwrite it the next time the value of another field is changed.

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 ,
Dec 04, 2020 Dec 04, 2020

This pointed me in the right direction. I found a method that is successful just using an "if" statement against one of the field lengths.

 

if (getField("ADDRESS_CITY").value.length >2) event.value =

this.getField("ADDRESS_CITY").valueAsString +", "+
this.getField("ADDRESS_STATE").valueAsString +" "+

this.getField("ADDRESS_POSTAL_CODE").valueAsString;

 

I could see myself getting in trouble if there is a city named "OY' or something ... but for the moment, this works. If there is a city in the data, we extract 'City, State Postal Code'. If there is a bad address, the user can populate the data field with data manually.

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