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

Auto populate fields with 'N/A' when signature field is completed

Explorer ,
Apr 29, 2022 Apr 29, 2022

Hi All,

I need some script help from the community!

 

I have a PDF form being used as part of a filling process operation. In short, the operators populate a field with data, then electronically sign next to the data. The signature then locks the field and makes it a read only. 

 

On occasion it is required for the operator to leave a field blank as it is not applicable ... but what I would like to is if there is a way for the blank field to be automatically populated with 'N/A' when the signature is applied if the field is left blank?

 

Thanks in advanced. !

TOPICS
PDF forms
1.6K
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 ,
Apr 29, 2022 Apr 29, 2022

You can place this script as a "Mouse enter" action in the signature field:

 

var oFld = this.getField("nameOfTheField");
if (oFld.value == oFld.defaultValue) {oFld.value = "N/A";}


Acrobate du PDF, InDesigner et Photoshoptographe
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 ,
Apr 29, 2022 Apr 29, 2022

JR Boulay, that would apply "N/A" before field is signed.

Perhaps it would be better to use 'On Blur' so it apply when field is signed, and you could use something like this:

var fields = ["Text A","Text B","Text C"];
for(var i in fields){
if(this.getField(fields[i]).valueAsString == "")
this.getField(fields[i]).value = "N/A";}

 

Replace "Text A","Text B","Text C" with your actual field names and you can easily add more names to it.

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
Explorer ,
Apr 29, 2022 Apr 29, 2022

This has worked! Thank you so much!

 

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 ,
Apr 29, 2022 Apr 29, 2022

Does this work when the user cancel the signing?

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 ,
Apr 29, 2022 Apr 29, 2022
LATEST

If user cancel signing and click outside sign field it will still populate fields with "N/A" which is probably what OP doesn't want.

If that would happen then it is better to use script under signed tab, if OP wants to set all fields to read-only after signing then he can use this:

var fields = ["Text A","Text B","Text C"];
for(var i in fields){
if(this.getField(fields[i]).valueAsString == "")
this.getField(fields[i]).value = "N/A";}

 

for (var j=0; j<this.numFields; j++){
this.getField(getNthFieldName(j)).readonly=true;}

 

If he wants some of the fields set to read only he can use this (changing/adding actual field names to variable 'fields' and 'fields2' where 'fields2' are fields to be set read-only) :

var fields = ["Text A","Text C"];
for(var i in fields){
if(this.getField(fields[i]).valueAsString == "")
this.getField(fields[i]).value = "N/A";}

 

var fields2 = ["Text field name","Checkbox field name","Button field name"];
for(var j in fields2){
this.getField(fields2[j]).readonly=true;}

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 ,
Apr 29, 2022 Apr 29, 2022

You can execute a script when the field is signed:

Bild1.jpgexpand image

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
Enthusiast ,
Apr 29, 2022 Apr 29, 2022

In that case he would need to implement read only part to the script also since he probably already using 'Mark as read-only'.

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