Modify script to address two automatic actions

I am using Adobe Pro XI, I have a script that will auto populate the date once digitally signed. I need to know how to also get the form to lock based on that signature as well. Looking at the Properties for SIGNED, it appears that I can only choose "lock all fields" or enter a script. The script I am currently using is:

var currentTime = new Date()

var month = currentTime.getMonth()+1

var day = currentTime.getDate()

var year = currentTime.getFulYear()

var signingTime = month+"/"+day+"/"+year

var f = this.getField("Date");

f.value = signingTime;

This works perfectly for auto-populating the date in another field, but I need to also lock the form.

I have tried using the Lock All Fields for the signature block and also use custom calculation for SignDate box to generate today's date, which I set to read only and hidden, and will display once signature is done. But if the person clicks cancel before they sign, the date populates and display's anyway...which defeats the purpose. (Hope that made sense..)

Is there something I can add to the script or something else I need to be doing that will auto populate the date only if signed AND if signed, lock all fields?


DHHS CDC


Voted Best Answer

You can modify your script in the SIGNED property to also make all fields readonly, such as this:

var currentTime = new Date()

var month = currentTime.getMonth()+1

var day = currentTime.getDate()

var year = currentTime.getFulYear()

var signingTime = month+"/"+day+"/"+year

var f = this.getField("Date");

f.value = signingTime;

for (var i = 0; i < this.numFields; i++) {
    var fname = this.getNthFieldName(i);
    this.getField(fname).readonly = true; // makes all fields readonly
}


By Almir R V Santos   


Please specify a reason: