mailtodanish | Posts: 47

How to get Signer detail with sessionUser

0 votes
we are receiving below notofication. {"@class":"com.silanis.esl.packages.event.ESLProcessEvent","name":"SIGNER_COMPLETE","sessionUser":"WvkDSx1Y7TwJ","packageId":"ZDpPk7usBE9clU9SHp_PllOB6As=","message":null,"documentId":null,"createdDate":"2019-01-01T12:04:28.213Z"} We want to get Signer Name from sessionUser and document name from documentId.

Duo_Liang | Posts: 3776

Reply to: How to get Signer detail with sessionUser

0 votes
Hi there, Here's some sample code for you:
		String packageId = "";
		String sessionUser = "";
		String documentId = "";
		
		com.silanis.esl.api.model.Package apiPackage = eslClient.getPackageService().getApiPackage(packageId);
		
		String documentName = null;
		for (com.silanis.esl.api.model.Document document : apiPackage.getDocuments()) {
			if(document.getId().equals(documentId)) {
				documentName = document.getName();
				break;
			}
		}
		
		
		String signerName = null;
		for (com.silanis.esl.api.model.Role role : apiPackage.getRoles()) {
			com.silanis.esl.api.model.Signer signer = role.getSigners().get(0);
			if(signer.getId().equals(sessionUser)) {
				signerName = signer.getFirstName() + " " + signer.getLastName();
                                break;
			}
		}
		
		System.out.println("document name: " + documentName);
		System.out.println("signer name: " + signerName);
Few things to notice: 1.sessionUser here is signer ID of the signer, which is only exposed from com.silanis.esl.api.model.Package (not com.silanis.esl.sdk.model.Package in most cases) 2.the callback event sending you this notification was "Recipient completed signing", which was not specified to a single document, that's why the payload says "documentId=null", but the sample code works when documentId is not null. Hope this could help! Duo

robadmiraal | Posts: 12

Reply to: How to get Signer detail with sessionUser

0 votes

I found a some simular posts on retrieving signer information of a package from the sessionUser from an eventmessage. But I did not find a solution for this. I'm using the .NET SDK.

I've added the signer to the package with CustomID "signer1", but in the eventmessage, the sessionUser is filled with a random guid.

In my code, i'm comparing the signer.Id to the sessionUser, but the signer.id contains "signer1" and the signerID contains "f6c714d6-ebe0-4d86-ab36-49d368fb1600" (passed from the sessionUser) and does not match.

                DocumentPackage documentPackage = ossClient.GetPackage(new PackageId(ID));

                foreach (OneSpanSign.Sdk.Signer signer in documentPackage.Signers)
                {
                    if (signer.Id == signerID)
                    {
                        signingResult.Text = signer.Email;
                        signingResult.Succes = true;
                        break;
                    }
                }

Is the are another way to get signer information from the sessionUser?


Duo_Liang | Posts: 3776

Reply to: How to get Signer detail with sessionUser

0 votes

Hi Rob,

 

Can I have the package ID of this transaction? My best guess is that this event is triggered by the sender whose signer id was randomly generated? If that's the case, explicitly add your sender as a signer and set the sender's custom ID as "Owner" in the package creation:
 

            DocumentPackage documentPackage = PackageBuilder.NewPackageNamed("Example Transaction") 
                                                .WithSigner(SignerBuilder.NewSignerWithEmail("your_sender_email")
                                                              .WithCustomId("Owner")
                                                              .WithFirstName("John")
                                                              .WithLastName("Smith"))

                                                    ......
                                                    .Build();

            PackageId packageId = ossClient.CreatePackageOneStep(documentPackage);

 

Duo


robadmiraal | Posts: 12

Reply to: How to get Signer detail with sessionUser

0 votes

Hello Duo,

 

The package ID is "iUXrAE4C5_2kpBF0Qd-Pz9t2Tmc=" in the sandbox environment. The person that signed has a custom ID of "signer1" and is not the owner. This is the event message I received:

{"@class":"com.silanis.esl.packages.event.ESLProcessEvent","name":"SIGNER_COMPLETE","sessionUser":"b562d757-3b5d-48cf-9277-8e8a7d818d61","packageId":"iUXrAE4C5_2kpBF0Qd-Pz9t2Tmc=","message":null,"documentId":null,"createdDate":"2023-07-20T11:47:02.686Z"}

I will implement you're solution to add the owner later, but for now I only need the information of signer1.

 

Thanks,

Rob


Duo_Liang | Posts: 3776

Reply to: How to get Signer detail with sessionUser

0 votes

Hi Rob,

 

Thanks for the information, I checked in the backoffice and indeed the signer's session user id is not signer1. Can you tell me more about this package, like is this package created out of a template? And can you share the code around the lines where you added the signer1 to the package builder?

 

Duo


robadmiraal | Posts: 12

Reply to: How to get Signer detail with sessionUser

0 votes

Hello Duo,

 

This is the code I use to create a package. At the end I update the capture fields to SignatureStyle.HAND_DRAWN and set the "AcceptanceFor" (in method UpdateSignatureFields).

The package is created from a Word document with text tags.

 

        private SigningResult CreatePackageOneSpan(SigningObject signingObject)
        {
            SigningResult signingResult = new SigningResult();

            try
            {

                CeremonyLayoutSettingsBuilder ceremonyLayoutSettingsBuilder = CeremonyLayoutSettingsBuilder.NewCeremonyLayoutSettings();
                DocumentPackageSettingsBuilder documentPackageSettingsBuilder = DocumentPackageSettingsBuilder.NewDocumentPackageSettings()
                        .WithCeremonyLayoutSettings(ceremonyLayoutSettingsBuilder);

                        .NewPackageNamed(signingObject.Name)
                        .WithEmailMessage(signingObject.EmailMessage)
                        .WithSettings(documentPackageSettingsBuilder)
                        .WithLanguage(new System.Globalization.CultureInfo("nl"));

                Int32 i = 0;

                Stream stream = new MemoryStream(signingObject.FileBytes);

                String guid = Guid.NewGuid().ToString();
                DocumentBuilder documentBuilder = DocumentBuilder.NewDocumentNamed(signingObject.FileName)
                .FromStream(stream, GetDocumentTypeOneSpan(signingObject.FileType))
                .WithId(guid)
                .EnableExtraction()
                .WithExtractionType(ExtractionType.TEXT_TAGS);

                foreach (Signer signer in signingObject.signers)
                {

                    SignerBuilder sb = SignerBuilder
                            .NewSignerWithEmail(signer.Email)
                            .WithFirstName(signer.FirstName)
                            .WithLastName(signer.LastName)
                            .WithCompany(signer.Company)
                            .WithCustomId($"signer{i+1}")
                            .WithLanguage(signer.GetCountryCode().ToLower())
                            .SigningOrder(i);

                    if (!String.IsNullOrWhiteSpace(signer.RequiredFile))
                    {
                        sb.WithAttachmentRequirement(new AttachmentRequirementBuilder(signer.RequiredFile).IsRequiredAttachment().Build());
                    }

                    packageBuilder.WithSigner(sb);

                    i++;
                }

                DocumentPackage package = packageBuilder
                    .WithDocument(documentBuilder)
                    .WithAttributes(new DocumentPackageAttributesBuilder().WithAttribute("senderVisible", false))
                    .Build();

                    OssClient ossClient = GetClientOneSpan();

                    PackageId packageId = ossClient.CreatePackageOneStep(package);
                    String sToken = ossClient.AuthenticationTokenService.CreateSenderAuthenticationToken(packageId);

                    signingResult.Succes = true;
                    signingResult.URL = $"{signingOptions.BASE_API_URL}/auth?senderAuthenticationToken={sToken}&target={signingOptions.BASE_API_URL}/a/transaction/{packageId}/designer";
                    signingResult.PackageId = packageId.ToString();

                    UpdateSignatureFields(ossClient, signingOptions, signingObject, packageId, guid);
 

            }
            catch (Exception ex)
            {
                signingResult.Succes = false;
                signingResult.Text = ex.Message;
            }

            return signingResult;

        }

        private void UpdateSignatureFields(OssClient ossClient, SigningOptions signingOptions, SigningObject signingObject, PackageId packageId, string Guid)
        {

            // Handtekeningvelden en reviewers bijwerken
            if (signingOptions.SignFromFile || signingObject.signers.Exists(x => x.AcceptOnly))
            {

                DocumentPackage createdPackage = ossClient.GetPackage(packageId);
                foreach (var doc in createdPackage.Documents)
                {
                    if (doc.Id == Guid)
                    {

                        if (signingOptions.SignFromFile)
                        {

                            List<Signature> captureSignatures = new List<Signature>();
                            foreach (var signature in doc.Signatures)
                            {
                                if (signature.Style == SignatureStyle.HAND_DRAWN)
                                {
                                    signature.FromFile = true;
                                    captureSignatures.Add(signature);
                                }
                            }

                            if (captureSignatures.Count > 0)
                            {
                                ossClient.ApprovalService.UpdateApprovals(createdPackage, doc.Id, captureSignatures);
                            }
                        }


                        foreach (var signer in signingObject.signers.Where(x => x.AcceptOnly))
                        {
                                ossClient.ApprovalService.AddApproval(createdPackage, doc.Id, SignatureBuilder.AcceptanceFor(signer.Email).Build());
                        }

                    }
                }

            }

        }
 

Hope this helps,

Rob


Duo_Liang | Posts: 3776

Reply to: How to get Signer detail with sessionUser

0 votes

Hi Rob,

 

I tried your code with SDK v11.49 but I can't reproduce the same. Could you recreate another transaction without manually modifying or signing, and share the package ID again?

 

Duo


robadmiraal | Posts: 12

Reply to: How to get Signer detail with sessionUser

0 votes

I'm using v11.49 as well. Just created a package with ID "KQZoRqDY8bMrt9KGi_P2hOEeG78=", without modifying or signing it.

Thanks.


robadmiraal | Posts: 12

Reply to: How to get Signer detail with sessionUser

1 votes

This morning I noticed that it seems to work fine all of a sudden.

What I changed last week, was that I update ALL signature fields when setting the FromFile property and not only the HAND_DRWAN signatures which need to be updated:

 

                            foreach (var signature in doc.Signatures)
                            {
                                if (signature.Style == SignatureStyle.HAND_DRAWN)
                                {
                                    signature.FromFile = true;
                                }
                                captureSignatures.Add(signature); // <= Moved this line, so all signatures are passed to 
UpdateApprovals

                            }

                            if (captureSignatures.Count > 0)
                            {
                                ossClient.ApprovalService.UpdateApprovals(createdPackage, doc.Id, captureSignatures);
                            }

 


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