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.

How to prevent form from executing initialize and calculate event when digitally sign

Avatar

Level 10

Hi forum,

I would like to know if anyone have any idea on how to stop the whole form from executing any event when it is digitally sign.

The only idea I have is to create a checkbox which is checked when the form is locked and then input an if statement within each events... but that is not really the best method...

8 Replies

Avatar

Level 7

What scripts do the scripts on your Initialize and Calculate events are you running?

Avatar

Level 10

On initialize event I change language EN/FR and calculate event changes the visibility of subforms...

When digitally sign nothing can be altered anymore, but when the form is re-opened all the code executes.

Even if nothing in the form changes at all, the form is considered altered for setting values even if it's setting them the same value they were...

Avatar

Level 7

What do you base the change on the Initialize event on? are you just automatically changing it to french? You may have to set a state for the form. Something that will be read by the initialize event and not make the change once it is already set.

Avatar

Level 10

Right... I guess I should have done this way before...

at this moment, I just set the value according to the language previously set when saved... maybe I should have a general function to verify if it needs to be set, hopefully this is gonna do the trick..

Thanks

Although any other ideas are welcome... it would be best to prevent all events from executing in case someone enters a field and exit or click anything... I can't believe a digital signature does not handle this behavior...

Avatar

Level 10

You can check the state of a signature field through a script an use the result to control if other script to be executed or not.

// Get the state of the signature field.

// NOTE: In XFA forms this works only by using getField() method with full SOM expresion, so keep the accessors [0]!

var oSignInfo = event.target.getField("form1[0].#subform[0].signature[0]").signatureInfo(),

    iSignState = oSignInfo.status;

// Execute only when form is unsigned

if (iSignState === 0 {

    // enter your code here

    …

}

Status Code Meaning

-1 Not a signature field

0 Signature is blank

1 Unknown status

2 Signature is invalid

3 Signature of document is valid, identity of signer could not be verified

4 Signature of document is valid and identity of signer is valid.

Avatar

Level 10

Hi radzmar,

Thanks for taking time to answer to this issue, I've tried multiple times before to use a similar method to get a signature field status with XFA dynamic forms. The only thing I ended up receiving was a message saying for security measures it can't get signature status as if it needs a trusted function...

the code it's executing is the following :

Am I missing anything?

Avatar

Level 10

If getField() returns null, the SOM couldn't be resolved this method. This is propably because digSignature.somExpression returns a somExpression beginning with xfa[0].form[0].…. Enter a SOM expression beginning with the root node of your form (i.e. form1[0]).

Avatar

Level 10

Alright I got it to work now... but not entirely

It seems to work only on the execution of the second initialize of the form, afterwards it still returns null.

Either in a click, initialize or calculate event, the getField returns null each time, it only returns the current signature status when the form is opened and initialize is fired twice because I execute initialize event of the form on docReady...