Help, signatureValidate() function doesn't work on hidden fields

a_c_hoff

17-03-2015

I am trying to use the signatureValidate() function to check if any signature fields are signed. I am doing this because I need to have the signature fields lock the form manually so that a specific department can make changes after signatures have been applied (via a password field). I got the signature fields to lock the form and I can unlock everything with a password dialog. However, I am trying to add some code to the Change event so that if a user clears their signature and no other signatures have been applied, then the form will unlock. I wrote a script that checks the signature validation of each signature field to verify that all of them are unsigned, and it works perfectly until one of the signature fields becomes hidden. Then the code just doesn't work. Am I doing something wrong? Is there a way to check if a signature field (which may or may not be hidden) has been signed? Below is the code that I am using:

var engMgrSig = event.target.getField("form1[0].Subform1[0].signatures[0].Eng_Manager[0].eng_manager_signature[0]").signatureValidate();

var mfgMgrSig = event.target.getField("form1[0].Subform1[0].signatures[0].Mfg_Eng_Manager[0].mfg_engr_signature[0]").signatureValidate();

if (mfgMgrSig == 0 && engMgrSig == 0)  {       

     oTargetField = this.resolveNode("ECO_table");

          oTargetField.access = "open";

}

else {

     oTargetField = this.resolveNode("ECO_table");

          oTargetField.access = "readOnly";

}

Accepted Solutions (0)

Answers (6)

Answers (6)

a_c_hoff

20-03-2015

Unfortunately I can't set the fields to white because they are within a flowed subform. I need them to be hidden so that they do not take up space and affect form layout. Otherwise, that would likely work.

jsanborn58

20-03-2015

You might also consider setting the signature font to white (effectively invisible), then conditionally changing the font to another color. The field would not have to start out as hidden, then.

a_c_hoff

18-03-2015

I discovered a dirty workaround that seems to solve the problem. I added several numeric fields that are hidden and in the postSign and the Change event of each signature field, I evaluate whether a signature was applied or removed and change the value of the numeric field to either a 0 or a 1. Then, instead of checking the signature fields for a signature, I check against the value of the hidden numeric field. This is a poor workaround, and if anyone is able to help me figure out how to actually check whether a signature has been applied to a signature field, that would be very much appreciated because I hate workarounds and I want to know that there is a way to do this (I strongly suspect that there is, because the code works unless the fields are hidden).

a_c_hoff

18-03-2015

The fields are supposed to be hidden when the form is opened, but can be "added" (made visible) by the user to allow for additional signatures. I use hidden fields rather than a simple Add Instance because of data binding issues.

I tried modifying the script to make the fields visible, fire the validation, and then hidden again, but for some reason it would either not work or it would make them visible after the first change and then hidden only if the field was changed again. Also, the code has to be able to recognize whether the fields were hidden before the code fired. If the were, they should be hidden afterwards. If they weren't then nothing needs to happen to them.

I have tried using an IF statement to run a validation on the fields based on which ones are visible, but that doesn't seem to work either. Here is an example:

   // this field is always visible

    var status = event.target.getField("form1[0].Subform1[0].signatures_REV1[0].Eng_Manager[0].eng_manager_signature[0]").signatureValidate();

 

    var engMgrSig2 = event.target.getField("form1[0].Subform1[0].signatures_REV1[0].Eng_Manager2[0].eng_manager_signature[0]").signatureValidate();

    var engMgrSig3 = event.target.getField("form1[0].Subform1[0].signatures_REV1[0].Eng_Manager3[0].eng_manager_signature[0]").signatureValidate();

   

    // this field is always visible

    var mfgMgrSig1 = event.target.getField("form1[0].Subform1[0].signatures_REV1[0].Mfg_Eng_Manager[0].mfg_engr_signature[0]").signatureValidate();

 

    var mfgMgrSig2 = event.target.getField("form1[0].Subform1[0].signatures_REV1[0].Mfg_Eng_Manager2[0].mfg_engr_signature2[0]").signatureValidate();

    var mfgMgrSig3 = event.target.getField("form1[0].Subform1[0].signatures_REV1[0].Mfg_Eng_Manager3[0].mfg_engr_signature3[0]").signatureValidate();

    //if all sig fields are visible

    if (this.resolveNode("signatures_REV1.Eng_Manager1").presence == "visible" && this.resolveNode("signatures_REV1.Eng_Manager3").presence == "visible" && this.resolveNode("signatures_REV1.Mfg_Eng_Manager2").presence == "visible" && this.resolveNode("signatures_REV1.Mfg_Eng_Manager3").presence == "visible") {

   

        if (status == 0 && mfgMgrSig1 == 0 && engMgrSig2 =0 && engMgrSig3 == 0 && mfgMgrSig2 == 0 && mfgMgrSig3 == 0)

        {       

            oTargetField = this.resolveNode("ECO_table");

                oTargetField.access = "open";           

        }

    }

   

    //if eng_mgr2 is visible

    if (this.resolveNode("form1.Subform1.signatures_REV1.Eng_Manager2").presence = "visible" && this.resolveNode("form1.Subform1.signatures_REV1.Eng_Manager3").presence = "hidden" && this.resolveNode("form1.Subform1.signatures_REV1.Mfg_Eng_Manager2").presence = "hidden" && this.resolveNode("form1.Subform1.signatures_REV1.Mfg_Eng_Manager3").presence = "hidden") {

   

       if (status == 0 && mfgMgrSig1 == 0 && engMgrSig2 =0)

        {       

            oTargetField = this.resolveNode("ECO_table");

                oTargetField.access = "open";

         }

    }

mouslander

18-03-2015

do you do anything to hide the field? Is that the expected behavior? If so then on  your script make the field visible, perform the check and make it hidden after.