kamranwali | Posts: 27

Add new signer to already signed document

0 votes

Is is possible to add a new signer to a document which is already signed?

I tried with below code

PackageId packageId = new PackageId("orB4GBrQKn33YIF6XJFgDMGdkb4=");

    ossClient.ChangePackageStatusToDraft(packageId);

 var package = ossClient.GetPackage(packageId);

    var document = package.GetDocument("SampleDocument");

    document.Signatures.Add(SignatureBuilder.SignatureFor("newemail")
                .OnPage(0)
                .AtPosition(100, 300)
                .Build());

ossClient.SendPackage(packageId);

but it didn't work (I did not get any error).

 

Then I tried with 

var package = ossClient.GetPackage(packageId);

    var document = package.GetDocument("SampleDocument");

    document.Signatures.Add(SignatureBuilder.SignatureFor("newemail")
                .OnPage(0)
                .AtPosition(100, 300)
                .Build());

    ossClient.PackageService.UpdateDocumentMetadata(package, document);

but got below error

{"messageKey":"error.validation.document.hasSignedApproval","message":"Document has been signed and cannot be edited.","code":400,"name":"Validation Error"}'

You can check transaction id: orB4GBrQKn33YIF6XJFgDMGdkb4=

 

Our requirement is once all the external parties sign all the documents then our internal staff will review the documents and e-sign them.

I am using WithoutAutomaticCompletion() so the transaction doesn't maked as completed automatically.


Duo_Liang | Posts: 3776

Reply to: Add new signer to already signed document

0 votes

Hi Kamran,

 

Thanks for your post! It's a general rule in OneSpan Sign that you can't edit a document when the document has been signed or partially signed. That's why you are receiving that 400 validation error.

If you are implementing the use case where the external parties sign first, then internal staff review and e-sign the document, you can add all the signatures during the first send and assign signing order to your signers to make sure the recipients sign in the expected sequence.

 

Duo


kamranwali | Posts: 27

Reply to: Add new signer to already signed document

0 votes

Hi Duo,

I can add a new signee through below code

 

   Signer signer = SignerBuilder.NewSignerWithEmail(email).WithFirstName("John1").WithLastName("Smith1").WithCustomId("Signer2").Build();

    PackageId packageId = new PackageId("8xu-O__qGDR_XlA0k9EncFv2mSw=");

    ossClient.ChangePackageStatusToDraft(packageId);

    String signerId = ossClient.PackageService.AddSigner(packageId, signer);

    ossClient.SendPackage(packageId);
    Console.WriteLine("Signer was added");

    CapturedSignature capturedSignature = new CapturedSignature("AQAAAIPGDPtxqL+RsL7/w/7eEX+cAtwAAwADAFAAAAADAAAAnALcACMAAAACq5ZQg105VH9Z/1l+UM9QF3A0v3BEv2BmYYFgSGAYQBZAJkA0QDVAREBmQENAQ0BRUJFQg1CDUFKbQENASUBGQERFUA==");

    ossClient.SignDocuments(packageId, "Signer2", capturedSignature);

    ossClient.PackageService.MarkComplete(packageId);

 

New signer gets the email and can sign the documents.


This code doesn't throw any error but the issue is document doesn't show the signatrure for Singer2 when we sign automatically through SignDocuments api.

CaptureSignature value I got from your sample code.

Can you please check why it is not showing the signatrue for Singer2?

I have attached both versions of document, before signing and after signing.

 

Do you have any webhook which notifies us after a singnee finished signing all the documents? So it about single signee not all the signees,

if there are two singees we want to be notified when each singee finishes signing the documents.

 

What the string represents in CapturedSignature? How can we generate it for our signature?

 

Thanks,

Kamran

 


Attachments
Duo_Liang | Posts: 3776

Reply to: Add new signer to already signed document

0 votes

Hi Kamran,

 

Thanks for the code snippet above!

For your questions:
#1 Signer2 signature didn't get populated because text tags (e.g. {{ * esl_SIG201:Signer2:signature}}) will only be extracted at the moment when the document was first uploaded. This is align with the rule above that "you can't add new signer to already signed document".

Like I suggested, you'll just need to add both Signer1 and Signer2 in the beginning and set their signing order. And in this path, you'll need the callback listener to notify your application when Signer1 finished signing, which will be covered in #2.

 

#2 Yes, you can definitely set up the notification events and expose a callback listener. When the event of interest happened, OSS callback service will send a POST call to your listener with payload similar to below:
{"@class":"com.silanis.esl.packages.event.ESLProcessEvent","name":"SIGNER_COMPLETE","sessionUser":"44aafb7c-97b9-40e1-bb59-eb76c7d2a484","packageId":"5n4obeO8jYoPp126Cm-Y3fxdfbo=","message":null,"documentId":null,"createdDate":"2018-06-30T20:12:12.272Z"}

By filtering by event name, signer role ID, and the package ID, your application knows the timing to auto sign for the internal signer.

 

#3 The CapturedSignature is a base64 encoded string, but it's not the traditional base64 image encoding. In our Community Code Share, we have sample codes to encode and decode the image in Java, .NET (a relative forum post here) and PHP.

 

Duo

 


kamranwali | Posts: 27

Reply to: Add new signer to already signed document

0 votes

Hi Duo,

 

Thanks for all the answers.

We will be using webhooks to decide when internal user should sign.

Regarding signer role ID, Which field it is mapped to in package?

PackageId packageId = new PackageId("Tu_u7xFf5F3YtgfXym8cdoW7nyA=");
var package = ossClient.GetPackage(packageId);

I checked the Signers collection but did not find any property for signer role ID.

Is there some other api we have to call? or it is mapped to some other field like Id?

 

I have one question regarding Text Tags valiation, can we restict text field to specific data type?

{{esl:Signer1:textfield:size(40,15),Maxlen(3)}}

for eg, we want a text field to only accept integers.

 

Thanks,

Kamran


Attachments
Duo_Liang | Posts: 3776

Reply to: Add new signer to already signed document

0 votes

Hi Kamran,

 

#1 For "signer role ID"

There are two IDs for a recipient, role ID and signer ID. However for SDK users, if you specified .WithCustomId() when adding the signer, these two IDs will be set to the same value as the custom ID:
.WithSigner(SignerBuilder.NewSignerWithEmail("[email protected]")
            .WithFirstName("Signer First Name")
            .WithLastName("Signer Last Name")
            .WithCustomId("Signer1"))

In this case, all of the "sessionUser", "signer role id", "role id", "signer id" can be referenced by OneSpanSign.Sdk.Signer.Id

 

#2 Integer only text field

This guide documents all the available syntax for text tags, where I believe the regular expression is not supported. In this case, I think you need a two step approach to achieve the goal:
Step1: when adding the text tags, define the field name using this syntax:
{{esl_textfield1:Signer1:textfield:size(40,15)}}

Step2: after uploading the document and before sending the transaction, retrieve the field and add a field validator, you can use code similar to below:
            PackageId packageId = new PackageId("w_UsvUrCMHNxmyHikCwFYWi2KqQ=");
            var package = ossClient.GetPackage(packageId);
            var document = package.GetDocument("SampleDocument");
            foreach (var signature in document.Signatures)
            {
                foreach (var field in signature.Fields)
                {
                    if ("textfield1" == field.Name)
                    {
                        FieldValidatorBuilder fb = FieldValidatorBuilder.Regex("^[0-9]*$")
                            .MaxLength(3)
                            .WithErrorMessage("Please enter a numeric value up to 3 digits!");
                        field.Validator = fb.Build();
                        ossClient.ApprovalService.ModifyField(packageId, document.Id, signature.Id, field);

                        break;
                    }
                }
            }

 

Duo

 

 


kamranwali | Posts: 27

Reply to: Add new signer to already signed document

0 votes

Hi Duo,

 

Thanks for the reply.

We are in the final stages of testing all our requirements.

I have one more question regarding completion email, how we can disable the email thats triggered after signee signs all the documents? We do not want to send any email when one or all signees sign the document.

I couldn't find any setting in the portal, I can see a setting where we can remove the download button but our requirement is to not send any completion email.

 

Thanks,

Kamran


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off