jdevalk | Posts: 9

CreatePackage with 1 signer and 2 signing Groups

0 votes
I attempting to create a document that has one signer by email, and 2 signing groups (lets name them Group1 and Group2) The document has EXTRACTION enabled. This is important as I need it to extract the Signature bound and unbound fields out of the document. The document for example has [Group1.Capture1] field where it needs to Capture the signature of a person in Group1. Now - I have created Group1 and Group2 in the eSignLive account. In my first attempt I Create the package and add the Group like .WithSigner(SignerBuilder.NewSignerFromGroup(new GroupId("Group1")) This fails the API returning a 500 error, someone has been notified. So after trying I figure out it DOES work if you pass the actual group id. .WithSigner(SignerBuilder.NewSignerFromGroup(new GroupId("fea96302-8e3d-43a9-8882-e28cb73e4b92")) Works! At least it gets past the Package creation and then proceeds to upload the document. The upload document works and it gets the Document upload response back. But now it proceeds to fail with a NullReference exception in SignatureConverter.cs ToSDKSignature() public Signature ToSDKSignature() { SignatureBuilder signatureBuilder = null; foreach ( Silanis.ESL.API.Role role in package.Roles ) { if ( role.Id.Equals( apiApproval.Role ) ) { if ( isPlaceHolder( role ) ) { signatureBuilder = SignatureBuilder.SignatureFor(new Placeholder(role.Id)); } else if ( isGroupRole( role ) ) { signatureBuilder = SignatureBuilder.SignatureFor(new GroupId(role.Signers [0].Group.Id)); } else { signatureBuilder = SignatureBuilder.SignatureFor(role.Signers [0].Email); } } } The offending code is where it compares apiApprovalId with the role.Id In the API response, the API returns the Group1 group signer with a Role.Id that equals it's Role Name! While the Role.Id in the internal package is equal to the GUID. So this seems inconsistent to me: The API does not allow a submit package unless I submit the GUID of the GROUP to sign. Fair enough. But then in the Response I get the GroupName back and the SDK has no way to resolve the Group Name with the GUID it gets back, resulting in signatureBuilder variable to be NULL after the loop. Am I calling the API wrong? Should calling the API with a Group Name work because I am getting a HTTP status 500 back. Is this a bug in the SDK? Please advise!

harishaidary | Posts: 1812

Reply to: CreatePackage with 1 signer and 2 signing Groups

0 votes
In my test, I created my RestClient through the API. When grabbing my group, I get the id as the GUID and the name as the group name. When retrieving roles in my package, I get both the name and id as the GUID. Let me know if this is what you meant. I do agree with you that it is cumbersome and that you should be able to retrieve your groups with the group name, or add a group signer with the group name since you would know your group names. I will go ahead and put a request for this through support.

jdevalk | Posts: 9

Reply to: CreatePackage with 1 signer and 2 signing Groups

0 votes
Here's what I am trying to achieve: ESign a document that has * 1 signer by email aka [Client.Capture1] * 2 group signers (Group1 and Group2) aka [Group1.Capture2] and [Group2.Capture3] The document is uploaded with EnableExtraction so the Groups are extracted by ESignLive. Result: On SDK 10.13 (latest from GitHub) this does not work without patching the SDK. Update: I fixed the issue but I needed to patch the actual .NET SDK to make it work, as in the translation between ApiDocument to SdkDocument some piece of information is not converted into the SdkDocument that is then used to lookup the Approvals of the Document you just uploaded. My patch is below. I do not know if this is the right patch to do, but for now it works. This is my code that I have now to call ESignLive API: (Note this is copy paste as I do not want to post the code to my actual package builder but this is what it produces in the end) PackageBuilder packageBuilder = PackageBuilder.NewPackageNamed(packageName) .DescribedAs(packageDescription) WithSigner(SignerBuilder.NewSignerWithEmail(clientEmail) .WithFirstName(clientFirstName) .WithLastName(clientLastName) .WithCustomId("Client") .SigningOrder(1)); WithSigner(SignerBuilder.NewSignerFromGroup(new GroupId("ed4d46cb-0d12-4a95-bdba-6a2ee8e17d6f")) .WithCustomId("Group1") .SigningOrder(2)); WithSigner(SignerBuilder.NewSignerFromGroup(new GroupId("fea96302-8e3d-43a9-8882-e28cb73e4b9")) .WithCustomId("Group2") .SigningOrder(3)); WithDocument(DocumentBuilder.NewDocumentNamed(document.Name) .WithDescription(document.Description) .FromFile(path) .EnableExtraction()) .WithInjectedField(FieldBuilder.TextField() .WithId("InjectedField") .WithName("InjectedField") .WithValue("TestValue") >>>> FAILS >>>> PackageId packageId = _eslClient.CreatePackage(documentPackage); Fails with NullReference exception in SignatureConverter.ToSdkSignature() Note 1 : If you call it with => NewSignerFromGroup(new GroupId("Group1")) This does not work in the sandbox environment, you get a HTTP ERROR 500 : internal API error So the only way to make it work is by specifying the GUID Note 2: By specifying the GUID in NewSignerFromGroup and because it is using EnableExtraction, now the API doesn't seem to be able to extract that "Group1" is a ESignLive Group. Because of this I have to call it with "WithCustomId("Group1")" and then it seems the extraction does work. Patch made in SDK: I have traced the problem I am experiencing to the following: It Creates the Package fine, and then proceeds to upload the document. After it Creates the package, the SDK gets the ID of the new package back and does GetPackage(id) on it, that will result in a copy of the Package (Api Package) as it then exists on the server. It will then proceed to upload the PDF document, and that will complete successfully. It will get a API Document back. The API Document needs to be converted to an SDK Document. The part failing here is when it tries to resolve the API Document approvals (signatures) to the package roles. Note it resolves the roles against the copy of the package that was returned by GetPackage() not the package that we uploaded originally. In the mapping between API Package to DocumentPackage, when it creates the Roles, it will miss copying a piece of information that was in the original package uploaded to ESignLive. This piece of information is the Group name (we have the ID though, the GUID) If the patch is not made, it goes into DocumentConverter, and that tries to Add the signatures. The signatures creation will call SignatureConverter.ToSdkSignature() and in there it will try to compare Package Role ID's against Document Approval ID's In the API call to upload a document, the JSON representation of the Document returned only states Role: "Group1". And as said above the fact that "Group1" equals a role is lost from converting API PAckage to SDK Document Package. Patch is to change this code: (DocumentPackageConverter.cs: line 176) foreach (Silanis.ESL.API.Role role in apiPackage.Roles) { if (role.Signers.Count == 0) { packageBuilder.WithSigner(SignerBuilder.NewSignerPlaceholder(new Placeholder(role.Id, role.Name))); } else if (role.Signers[0].Group != null) { packageBuilder.WithSigner(SignerBuilder.NewSignerFromGroup(new GroupId(role.Signers[0].Group.Id))); } else ..... Into this: foreach (Silanis.ESL.API.Role role in apiPackage.Roles) { if (role.Signers.Count == 0) { packageBuilder.WithSigner(SignerBuilder.NewSignerPlaceholder(new Placeholder(role.Id, role.Name))); } else if (role.Signers[0].Group != null) { /// THE CODE BELOW WithCustomId() injects the custom ID that comes back from ESignLive API Document into the SDK Document, else it gets lost. SignerBuilder signerBuilder = SignerBuilder.NewSignerFromGroup(new GroupId(role.Signers[0].Group.Id)) .WithCustomId(role.Signers[0].Group.Name); packageBuilder.WithSigner(signerBuilder); } .....

jdevalk | Posts: 9

Reply to: CreatePackage with 1 signer and 2 signing Groups

0 votes
Another note that the Groups are not created through the API but they are created in the ESignLive web console / account administration. The EnableExtraction I assume to be able to resolve Groups in uploaded documents created both through the API and through the Web console / account administration. Also it seems to me purely a .NET SDK mapping issue as when you inspect the JSON from the package returned and the document returned after upload, they do resolve correctly and all the information is there. Also after upload if you inspect the packge in eSignLive console in Drafts then you can see the fields were resolved correctly (extracted) to the Groups by ESignLive. After making the patch above to the SDK code, you can complete the signing ceremony and no more NullReference error is thrown with converting the Api Document to the Sdk Document in setting up the package.

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