Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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;}
Copy link to clipboard
Copied
Thank you ... it was the 'if' statement.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more