Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Stumped on syntax - signature validation

Avatar

Level 2

I'm putting script in the "validate" event for my signature, so that when the form is validated, two fields will toggle on and off.  The field is called "AsstDean".  I get the error "null is not an object", and I'm just stumped.  I tried to follow the example from the LiveCycle help, but there is something off with my syntax.  Any help would be appreciated.  Thanks!

status = event.target.getField("AsstDean[0]").signatureValidate();

if (status < 3)

        {

        Program.presence = "hidden";

        Incomplete.presence = "visible";

        }

else

        {

        Program.presence = "visible";

        Incomplete.presence = "hidden";

        }

7 Replies

Avatar

Level 2

I have, by the way, previously (in the same script) defined "status" as a variable:

The first line of the script is "var status = 1;" - I was previously checking the other code.

Avatar

Former Community Member

I think that you will need the full path to that field. If you click on the AsstDean field and look in the script editor. The fiest line will show you the AcroForm field name that you will need.....something like this:

form1[0].Page1[0].AsstDean[0]

Paul

Avatar

Level 2

The grey area in the area of the script I'm putting this script says:

form1.Page1.Approval.AsstDean::validate - (JavaScript, client)

So, I put the following as the status check line:

status = event.target.getField("form1[0].Page1[0].Approval[0].AsstDean[0]").signatureValidate();

I get the error " Error: null is not an object"

Avatar

Former Community Member

Can you share your form and I wil have a look?

Paul

Avatar

Level 2

Sure... I've attached it.  Being self-taught, I'm sure there is plenty to critique.

It's not finished yet - I need to do some polishing - but the only bug in it is the signature validating.  I basically want to toggle two different subforms on and off when the form is signed/unsigned.

The field that I'm working on is on the next to last page of the form.

Avatar

Former Community Member

Ok after much testing I found that the code will not work unless the field is visible. The commands to get the signature field and validate are AcroForm commands. When the form loads there is no reference to the signature from AcroForms until the page that holds that signature exists.

ON a separate note .... I did find that if I reduce the target version from 8 to 7.0.5 then it worked fine. So clearly the way these signature objects are handled changed between version 7.05 and 8

I also found a couple of Blog entries by Lee Sutton who has some good samples around signatures. Here they are:

http://blogs.adobe.com/livecycle/2007/12/accessing_properties_of_a_digi.html

http://blogs.adobe.com/livecycle/2008/06/clearing_a_signature_field_on.html

Paul

Avatar

Level 2

The examples were just what I needed - thanks for pointing me to them.  Not sure why I couldn't find them with my own searching!

I did get the code to work even when the signatures were hidden.  I moved the code from the VALIDATE event to the CHANGE event - this is what I noted in the examples. The working code is:

var status = event.target.getField("form1[0].Page1[0].Approval[0].AsstDean[0]").signatureValidate();

if (status < 3)
    {
    Program.presence = "hidden";
    Incomplete.presence = "visible";
    }
else
    {
    Program.presence = "visible";
    Incomplete.presence = "hidden";
    }

form1, Page1, and Approval are all subforms, while the signature field is named "AsstDean"

This code checks if the signature is present.  If it is, one subform is visible.  If it isn't, another subform is visible.  I also needed the entire root reference for the field.