FredericDH | Posts: 51

Adding documents when using a template

0 votes
I have created a template in my eSignLive account. As the UI requires, I have uploaded a document. I have been trying to create a transaction using this template, however, I need to add documents to this transaction, on top of the ones provided in the template. Looking at the eSignLiveTemplate documentation (https://developer.esignlive.com/guides/feature-guides/templates/), it doesn't seem possible Am I missing something ? is it really not possible ?

Approved Answer
mwilliams | Posts: 957

Reply to: Adding documents when using a template

1 votes
Unfortunately, it doesn't appear that the CreatePackageFromTemplate docPackage "delta" parameter actually adds the additional document. The below will work though:
PackageId templateId = new PackageId("TEMPLATE_ID");

            DocumentPackage docPackage = PackageBuilder.NewPackageNamed("Built from Template")
                    .WithSigner(SignerBuilder.NewSignerWithEmail("EMAIL_ADDRESS")
                                .WithFirstName("FNAME")
                                .WithLastName("LNAME")
                                .WithCustomId("MySigner1")
                                .Replacing(new Placeholder("Placeholder1")))
                    .Build();
            
            PackageId packageId = eslClient.CreatePackageFromTemplate(templateId,docPackage);

            Document myDoc = DocumentBuilder.NewDocumentNamed("sampleAgreement2")
                                  .FromStream(fileStream2, DocumentType.PDF)
                                  .WithSignature(SignatureBuilder.SignatureFor("EMAIL_ADDRESS")
                                    .AtPosition(165, 400)
                                    .OnPage(0)
                                    .WithField(FieldBuilder.SignatureDate()
                                        .AtPosition(365, 400)
                                        .OnPage(0))
                                    .WithField(FieldBuilder.Label()
                                        .AtPosition(165, 450)
                                        .WithId("mylabel")
                                        .OnPage(0)
                                        .WithValue("Some Value"))).Build();

            eslClient.UploadDocument(myDoc, packageId);

//ToDo: send package
Hope this helps. Let me know.

mwilliams | Posts: 957

Reply to: Adding documents when using a template

0 votes
Hey Frederic, You can definitely add documents to a template at any time. It would just be like adding documents to a package: https://developer.esignlive.com/guides/feature-guides/document-management/#net-sdk You should also be able to add documents on the fly when creating a package from a template: https://developer.esignlive.com/guides/feature-guides/create-package-from-template/#net-sdk You'd just need to add a document to the document package delta (newPackage in this example) and specify your signature/field locations as in the document management guide above. Let me know if you have issues and I'll take a closer look.

FredericDH | Posts: 51

Reply to: Adding documents when using a template

0 votes
Thanks for your response. It seems that I am using the right code but the transaction is only containing the documents from the template. Below is my code : packageId = eslClient.CreatePackageFromTemplate(templateId, package); (witb package containing documents and signers. templateId is the Id of a template containing one document and one signer). What I found is that, if I upload the documents after the code above, it seems to work (see code below). But that doesn't make sense, why would I need to upload the document explicitely even though they are already contained in my Documentpackage "package" ?? foreach (Document doc in package.Documents) { eslClient.UploadDocument(doc,packageId); } Also, is it normal that the signers in the template have a signing order of 2 and the signers from my package have a signing order of 3 ?

mwilliams | Posts: 957

Reply to: Adding documents when using a template

0 votes
I'd have to see your full code to see exactly what you're trying that's working and what's not working and to try to explain the signing orders. Can you post the entire code that relates to this issue, here? If not, can you send it to [email protected]?

mwilliams | Posts: 957

Reply to: Adding documents when using a template

0 votes
And the reason that the above code to add documents works only after doing the create package from template line is that the package doesn't exist in eSignLive until after you've created it with that line? So, attempting to add a document before it's created would not work, but maybe I'm misunderstanding.

FredericDH | Posts: 51

Reply to: Adding documents when using a template

0 votes
"And the reason that the above code to add documents works only after doing the create package from template line is that the package doesn’t exist in eSignLive until after you’ve created it with that line? So, attempting to add a document before it’s created would not work, but maybe I’m misunderstanding." I am confused... so what is the purpose of passing a DocumentPackage in the function eslClient.CreatePackageFromTemplate(templateId,package) if the package has to exist already in eSignLive ? I will provide my code shortly as I am making it suitable for this thread Thanks

mwilliams | Posts: 957

Reply to: Adding documents when using a template

0 votes
I wasn't saying that the package had to exist already. You had said that you were only able to add the document with your above code AFTER calling the createPackageFromTemplate call. I just agreed that this was definitely how you'd have to do it because the package doesn't exist in eSignLive until you make that call. That is all. :) I'll wait for your code to see what I see there.

FredericDH | Posts: 51

Reply to: Adding documents when using a template

0 votes
Oh definitely, I was more wondering why the package was not created (headbang...) :-) Please find below my code, I hope that you can find what I am doing wrong : string base64StringElement = "";//ommitted for more clarity string fileNameElement = "Test.pdf"; byte[] fileBytes = Convert.FromBase64String(base64StringElement); Document document = new Document(); using (MemoryStream fileStream = new MemoryStream(fileBytes)) { document = DocumentBuilder .NewDocumentNamed(fileNameElement) .WithId("GUID") .FromStream(fileStream, DocumentType.PDF) .Build(); } Signer signer = SignerBuilder.NewSignerWithEmail("[email protected]") .WithFirstName("John") .WithLastName("Smith") .SigningOrder(1) .Build(); DocumentPackage documentPackage = PackageBuilder .NewPackageNamed("Test Package merged with a template") .WithSettings( DocumentPackageSettingsBuilder.NewDocumentPackageSettings()) .ExpiresOn(DateTime.Today.AddDays(5)) .Build(); documentPackage.Signers = new List { signer }; documentPackage.Documents.Add(document); PackageId packageId = eslClient.CreatePackageFromTemplate( templateId, documentPackage); eslClient.SendPackage(packageId);

FredericDH | Posts: 51

Reply to: Adding documents when using a template

0 votes
Ok, thanks you for confirming this behavior. Do you think it's a bug or a feature ? Looking at the name of the function CreatePackageFromTemplate() and the parameter "documentPackage", I would understand that the documents in the package would be uploaded automatically but I could be wrong. I will use your solution for now. Thank you again a lot for your help and time, as always you guys are very responsive, thumbs up !! Frederic

FredericDH | Posts: 51

Reply to: Adding documents when using a template

0 votes
Oh, I forgot to ask : Is there a way to modify the signing order when using the template ? By default, the recipients in the template have a signing order of 2 and the recipients in the package created in the code have a signing order of 3 ?

mwilliams | Posts: 957

Reply to: Adding documents when using a template

0 votes
I would probably say this is how it was probably intended to work, but the naming hint "delta" inside the SDK of CreatePackageFromTemplate(templateId, DocumentPackage delta) would say to me that whatever changes there are between this "delta" document package and the current template will be merged. So, it's most likely that this would have to be an Enhancement Request vs it being accepted as a bug. I can see it from both ways, but it seems just as easy to call CreatePackageFromTemplate and then simply add the extra documents after. It doesn't change the complexity or amount of code too much. It's more a matter of order. As for the order, can you explain this a bit more? Are you using placeholders in the template and just replacing them with the signer info? Or are you also adding a new signer? If so, why are you not using a placeholder for this other signer? Let me know.

FredericDH | Posts: 51

Reply to: Adding documents when using a template

0 votes
Sure, we could debate whether it's an enhancement request or a bug... but to me, I don't see the purpose of passing a DocumentPackage to the function "CreatePackageFromTemplate" if the documents are not taken into account. In the end, your solution works, it's just that it is not very intuitive at first. As for the signing order, sorry I was not clear enough. When I end up with my transaction, the template signer (Brad Smith for example) and the signer (John Smith) created in the package end up with different signing orders. For some reason, Brad has a signing order of 2 and John of 3. I am not using placeholders no, should I ? I am not sure to understand the need of it but would be open to any suggestions.

mwilliams | Posts: 957

Reply to: Adding documents when using a template

0 votes
I agree that it's not too straightforward, but the reason a document package is necessary is that you can set package level settings, like description, in-person, attributes, replace signer placeholders, etc. I am with you that it would seem that you should be able to add new documents here as well. Posting in the Enhancement Ideas forum and/or contacting [email protected] to express the wish for this ER would be the way to go, here, I think. Since you're using templates, placeholders would make things much easier on you. If you add a placeholder signer, you can add signatures for that signer in the template, then, as in my code above, when you create the documentPackage that's used to create the package from the template, you just specify the .Replacing(placeholder) line and the placeholder is auto updated with the info you have there and all signatures/fields are converted to that signer. If you don't specify a "SigningOrder()" on any signer, they should all end up in parallel without a signing order. If you're not worried about the order, I would try removing that line or make sure you put them all at 0 or something like that. Let me know.

FredericDH | Posts: 51

Reply to: Adding documents when using a template

0 votes
Thanks for the placeholder explanation and example. That is assuming that we want t use the placeholder in the template. However, in my case, the signer from the package is always different than the one in the template and actually they would never be the same. In this case, I have set up up the signing order when building my signer but it still gets, in the end, the signing order of (PlaceHolder Signing Order) + 1. I hope that makes sense

mwilliams | Posts: 957

Reply to: Adding documents when using a template

0 votes
That's the point of it though. There doesn't have to be a named signer. It's just a placeholder. You don't specify a first/last name or email address. You only name the signer(s) at package create time. Let me know.

FredericDH | Posts: 51

Reply to: Adding documents when using a template

0 votes
Ok but i can never know the number of signers that will be in the transaction. It can be 1, it can be 30...etc.

mwilliams | Posts: 957

Reply to: Adding documents when using a template

0 votes
Okay. I understand. So, if you use no placeholders or static signers in the template and specify 0 for the signing order for all signers that you add, do you have an issue with how the ceremony works out? Let me know!

FredericDH | Posts: 51

Reply to: Adding documents when using a template

0 votes
Good point! If I set the signing order for all signers that I add to 0, then, everyone (template signer included) seems to have a signing order of 0. In the case where I assign a signing order greater than 0, then it seems that the signers in the template have the priority over the added signers. Thanks for recommendation, I will adapt my code to cover that case when using templates

mwilliams | Posts: 957

Reply to: Adding documents when using a template

0 votes
Great! Glad we were able to find a solution! :)

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