Search code examples
javascriptformslockingadobefield

Lock all fields of a form if two signatures are provided (Adobe forms with JavaScript)


I want to lock all fields in a form I generated with Adobe Standard if two signatures are provided. In order to do so I have generated two signature fields. In this fields I would like to use JavaScripts to perform the action. Here is my first try:

var uu = this.getField("Unterschrift_User") // User-Unterschrift holen
var uv = this.getField("Unterschrift_Vorgesetzt")//Vorgesetzten-Unterschrift holen
var status_uu = uu.signatureValidate();
var sigInfo_uu = uu.signatureInfo();
var status_uv = uv.signatureValidate();
var sigInfo_uv = uv.signatureInfo();
//var lockFields = uu.getLock();
//lockFields.action = "All";
var lockFields = {action:"All"};
if (status_uu > 3 && status_uv > 3)
{
    //var msg = "Unterschrift ist gültig " + sigInfo_uu.statusText;
    uu.setLock(lockFields);
}
else
{
    //do nothing
}

But this obv does not work. Errors Thrown in the console:

NotAllowedError: Sicherheitseinstellungen verhindern den Zugriff auf diese Eigenschaft oder Methode. = "Security settings prevent access to this property or method."
Field.setLock:18:Field Unterschrift_User:Format

Note: This is probably (and hopefully) the one and only form I will ever have to generate With Adobe Standard. So please forgive me, that I dont want to read a bunch of documentation...

Can somebody give me a hint, what to do here? Thanks in advance!


Solution

  • The solution was in my case to pass getField("field_n").readonly = true; to every field i wanted to lock.