jobou363

Update package is not working

0 votes
What is the recommended way to update a package to use the new filled document? Should I delete the package and create another one. I'm trying to update a package but the document inside is never updated and stay the same as when first created. Here is the creation and update: var packageBuilder = CreatePackageBuilder(adhesionEnLigneEvent); var packageId = new PackageId(adhesionEnLigneEvent.PackageId); eslClient.ChangePackageStatusToDraft(packageId); eslClient.UpdatePackage(packageId, packageBuilder.Build()); eslClient.SendPackage(packageId); Here is the first creation : var packageBuilder = CreatePackageBuilder(adhesionEnLigneEvent); var packageId = eslClient.CreatePackage(packageBuilder.Build()); eslClient.SendPackage(packageId); Code that creates de documents : private static PackageBuilder CreatePackageBuilder(InfoAdhesionEnLigneEvent adhesionEnLigneEvent) { var fieldValidatorString = new FieldValidator { MaxLength = 100 }; var path = AppDomain.CurrentDomain.BaseDirectory; var directory = Path.GetDirectoryName(path); var fileInfo = new FileInfo(directory + "/OneSpan/AdhesionFormulaire_TextTags.pdf"); var pdfFileStream = System.IO.File.OpenRead(fileInfo.FullName); var regimeAbbreviation = adhesionEnLigneEvent.InfoAdhesionEnLigne.Regime.Abbreviation; var packageName = $"Adhésion {regimeAbbreviation} - {adhesionEnLigneEvent.Prenom} {adhesionEnLigneEvent.Nom}"; var signerId = adhesionEnLigneEvent.SignerId.ToString(); var documentBuilder = DocumentBuilder.NewDocumentNamed("Formulaire d'adhésion") .FromStream(pdfFileStream, DocumentType.PDF) .WithExtractionType(ExtractionType.ACROFIELDS) .EnableExtraction() .WithSignature(SignatureBuilder.SignatureFor(adhesionEnLigneEvent.Courriel) .WithId(new SignatureId("Signature")).WithName("Signature") .WithPositionExtracted()) .WithInjectedField(FieldBuilder.TextField().WithName("Nom") .WithValidation(fieldValidatorString).WithValue(adhesionEnLigneEvent.Nom)) .WithInjectedField(FieldBuilder.TextField().WithName("Prenom") .WithValidation(fieldValidatorString).WithValue(adhesionEnLigneEvent.Prenom)) .WithInjectedField(FieldBuilder.TextField().WithName("Nas") .WithValue(adhesionEnLigneEvent.Nas.ToString())) .WithInjectedField(FieldBuilder.TextField().WithName("AdresseLigne1") .WithValue(adhesionEnLigneEvent.GetAdresseLigne1Format())) .WithInjectedField(FieldBuilder.TextField().WithName("AdresseLigne2") .WithValue(adhesionEnLigneEvent.GetAdresseLigne2Format())) .WithInjectedField(FieldBuilder.TextField().WithName("NoEmploye") .WithValidation(fieldValidatorString).WithValue(adhesionEnLigneEvent.NoEmploye)) .WithInjectedField(FieldBuilder.TextField().WithName("Sexe") .WithValue(adhesionEnLigneEvent.GetSexeFormulaire())) .WithInjectedField(FieldBuilder.Datepicker().WithName("DateNaissance") .WithValue(adhesionEnLigneEvent.DateDeNaissance.GetValueOrDefault().ToString("yyyy-MM-dd"))) .WithInjectedField(FieldBuilder.SignatureDate().WithName("DateSignature") .WithValue(DateTime.Now.ToString("yyyy-MM-dd"))) .WithInjectedField(FieldBuilder.Datepicker().WithName("DateEmploi") .WithValue(adhesionEnLigneEvent.DateEmploi.GetValueOrDefault().ToString("yyyy-MM-dd"))) .WithInjectedField(FieldBuilder.Datepicker().WithName("DateAdhesion") .WithValue(adhesionEnLigneEvent.DateAdhesion.GetValueOrDefault().ToString("yyyy-MM-dd"))) .WithInjectedField(FieldBuilder.TextField().WithName("NomConjoint").WithValidation(fieldValidatorString).WithValue(adhesionEnLigneEvent.NomConjoint)) .WithInjectedField(FieldBuilder.TextField().WithName("PrenomConjoint").WithValidation(fieldValidatorString).WithValue(adhesionEnLigneEvent.PrenomConjoint)) .WithInjectedField(FieldBuilder.TextArea().WithName("Commentaire").WithValidation(fieldValidatorString).WithValue(adhesionEnLigneEvent.Commentaire)); var indice = 1; foreach (var adhesionEnLigneBeneficiaire in adhesionEnLigneEvent.beneficiaires) { var lienParente = LienParentes.List().ElementAt(adhesionEnLigneBeneficiaire.LienParente).Value; documentBuilder.WithInjectedField(FieldBuilder.TextField().WithName("NomBeneficiaire" + indice).WithValidation(fieldValidatorString).WithValue(adhesionEnLigneBeneficiaire.Nom)); documentBuilder.WithInjectedField(FieldBuilder.TextField().WithName("PrenomBeneficiaire" + indice).WithValidation(fieldValidatorString).WithValue(adhesionEnLigneBeneficiaire.Prenom)); documentBuilder.WithInjectedField(FieldBuilder.TextField().WithName("LienParente" + indice).WithValidation(fieldValidatorString).WithValue(lienParente)); documentBuilder.WithInjectedField(FieldBuilder.TextField().WithName("Pourcentage" + indice).WithValidation(fieldValidatorString).WithValue((adhesionEnLigneBeneficiaire.Pourcentage / 100).ToString("P"))); indice++; } var document = documentBuilder.Build(); return PackageBuilder.NewPackageNamed(packageName) .WithSettings(DocumentPackageSettingsBuilder.NewDocumentPackageSettings() .WithoutInPerson() .WithoutLanguageDropDown() .WithoutOptOut() .WithoutDecline() .WithHandOverLinkHref("http://www.google.ca") .WithHandOverLinkText("click here") .WithHandOverLinkTooltip("link tooltip") .WithCeremonyLayoutSettings(CeremonyLayoutSettingsBuilder.NewCeremonyLayoutSettings() .WithoutSessionBar() .WithoutBreadCrumbs() .WithoutGlobalConfirmButton() .WithGlobalDownloadButton() .WithLogoImageSource("https://mon.saiadnet.qc.ca/Content/images/logoSAI-gauche-img.jpg"))) .WithSigner(SignerBuilder.NewSignerWithEmail(adhesionEnLigneEvent.Courriel) .WithFirstName(adhesionEnLigneEvent.Prenom) .WithLastName(adhesionEnLigneEvent.Nom) .WithCompany(regimeAbbreviation) .WithCustomId(signerId) .WithLanguage("fr")) .WithDocument(document); }

Reply to: Update package is not working

1 votes
Hey jobou363, Welcome to OneSpan Sign! Before we discuss how to update a package/document by SDK, please share more about your use case, because it depends on whether your document has been partially signed and what kind of information you'd updated. Let's expend it a little bit: (1) If any one of your signers has started signing the document, you have to follow the delete-and-recreate process to update it in order to eliminate possibility that you would change the document content. (2)If it's before signing (2.1) if you simply wanted to update document level attributes like document name or description, grab your document object first, do the changes and call UpdateDocumentMetadata function (or rebuilt the document object with updated info like below), which is documented in Document Management guide:
Document document = DocumentBuilder.NewDocumentNamed("Example Document")
	.WithName("Updated document name")
	.WithDescription("Updated document description")
        .Build();
eslClient.PackageService.UpdateDocumentMetadata(documentPackage, document);
(2.2)but if you wanted to update anything related to signature/fields, you’d update signature/approval level instead (again, you can Grab the existing signature object, do the changes then update vs Rebuilt the object then update), which is documented in Signatures guide:
Signature updatedSignature = SignatureBuilder.CaptureFor("[email protected]")
                      .OnPage(0)
                      .AtPosition(215, 510)
                      .WithSize(300, 50)
                      .WithId(new SignatureId("signature1"))
                      .Build();

IList signatures = new List();
signatures.Add(updatedSignature);

DocumentPackage updatedPackage = client.GetPackage(packageId);
client.ApprovalService.UpdateApprovals(updatedPackage, documentId, signatures);
Hope this could help! Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Update package is not working

0 votes
I can see where my problem is. In some cases the user will exit et restart the process later but he has already started the signing. I have change to use the delete-and-recreate process and I don't have the problem.

Reply to: Update package is not working

0 votes
Glad that you figured it out! Please let us know if you have any other issues!

Duo Liang OneSpan Evangelism and Partner Integrations Developer


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