Archive for June, 2011

Required Digital Signatures in LiveCycle form

Description:
Recently, I had a project in which a form was being routed to three people in a serial fashion. However, prior to submitting the form we wanted to test whether the current user had signed the form in his/her designated spot. In order for the digital signatures to remain valid we could not make adjustments to the XML Schema and then use the RenderForm activity in LiveCycle– signatures would have been broken. So we had to put all the code to handle this in the form.

Situation:
There are three roles, Employee, Supervisor, and Reviewer. The form is routed through a LiveCycle process in that order. The Supervisor and Reviewer can either Approve or Decline the form. If the form is Declined it gets routed back to the Employee.

Setting up the form:

  • Add a Text Field, name it requiredSignature, and set its presence to Invisible and set its value to “Employee”
  • Add 3 digital signature fields and named them: employeeSignature, supervisorSignature, and reviewerSignature
  • Put the Approve/Decline option as a drop-down list into the form instead of in Workspace User Action so we did not have to depend on the AWS_ACTION drop down and Form Bridge because we are submitting as a PDF due to the digital signatures, everything is self-contained in the form.
  • The bottom of the form looks like this:

    Three Digital Signatures

    Three Digital Signatures

 

Code:

Three things you should know about the following code:

  1. signatureValidate returns:
    -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.
  2. event.target.getField() you must include [0] in order target the designated field.
  3. [signatureField].mandatory makes that signatureField required prior to submit; [signatureField].disabled makes that signatureField no longer required in order to submit the form.

To be placed on the in the preSubmit Event for the form:

if (requiredSignature.rawValue==”Employee”){

var oState = event.target.getField(“employeeSignature[0]”).signatureValidate();

if (oState > 3){

employeeSignature.mandatory = “disabled”;
requiredSignature.rawValue=”Supervisor”;

}
else{

employeeSignature.mandatory = “error”;

}

}

else if (requiredSignature.rawValue==”Supervisor”){

var oState = event.target.getField(“supervisorSignature[0]”).signatureValidate();

if (oState > 3){

supervisorSignature.mandatory = “disabled”;
requiredSignature.rawValue=”Reviewer”;

}
else{

supervisorSignature.mandatory = “error”;

}

}else if(requiredSignature.rawValue==”Reviewer”){

var oState = event.target.getField(“reviewerSignature[0]”).signatureValidate();
if (oState > 3){

reviewerSignature.mandatory = “disabled”;

}

else{

reviewerSignature.mandatory = “error”;

}

}

else if(requiredSignature.rawValue==”Decline”){

requiredSignature.rawValue=”Employee”;

}

 

On the Supervisor Approve/Decline Drop-down list add the following code to the exit Event:

var oState = event.target.getField(employeeSignature[0]”).signatureValidate();

if(this.rawValue == “Approve”){

if (requiredSignature.rawValue==”Supervisor”){
//do nothing


}

else if(requiredSignature.rawValue==”Decline”){

requiredSignature.rawValue=”Supervisor”;

if (oState > 3){

supervisorSignature.mandatory = “error”;

}

supervisorSignature.presence = “visible”;
supervisorSignatureDate.presence = “visible”;

}

}

else{

if (requiredSignature.rawValue==”Supervisor”){

if (oState > 3)
{

requiredSignature.rawValue=”Decline”;

}
supervisorSignature.mandatory = “disabled”;

}

supervisorSignature.presence = “hidden”;
supervisorSignatureDate.presence = “hidden”;

}

 

Result:

If an Employee attempts to Submit the form without signing the form, he/she will get the following Error Message:

Employee Signature Error Message

Employee Signature Error Message