This topic contains 6 replies, has 2 voices, and was last updated by  nehme 2 months, 1 week ago.

  • Author
    Posts
  • Participant
    nehme
    Senior Member
    Member since: 23.07.2018
    Number of posts: 101

    Hello,

    I have already a template with 2 placeholders called Signer1 and Signer2.

    When creating a document packge from the template, how I can update these placeholders to add the email address and first and last name for the signers.

    Do you have such an example? Already my placeholder created inside a template in sandbox.

    Thanks

    Keymaster
    Duo_Liang
    Guru
    Member since: 14.06.2018
    Number of posts: 398

    Score

    0

    Hi nehme,

    Below is the API and a JSON example for update placeholders:

    POST /api/packages/{template ID}/clone
    
    {
       "name":"Package created from template through REST API",
       "status":"SENT",
       "roles":[
          {
             "id":"role ID for signer1",
             "type":"SIGNER",
             "signers":[
                {
                   "id":"signer1ID",
                   "firstName":"1.firstname",
                   "lastName":"1.lastname",
                   "email":"signer1@mailinator.com"
                }
             ],
             "name":"Role1 Name"
          },
          {
             "id":"role ID for signer2",
             "type":"SIGNER",
             "signers":[
                {
                   "id":"signer2ID",
                   "firstName":"2.firstname",
                   "lastName":"2.lastname",
                   "email":"signer2@mailinator.com"
                }
             ],
             "name":"Role2 Name"
          }
       ]
    }

    From my experience, if you create the template from WebUI, your roles’ IDs will be generated randomly, so I’d suggest to create templates through calling API/SDK.
    Hope this could help you!

    Duo


    Duo Liang
    OneSpan Junior Technical Evangelist
    • This reply was modified 2 months, 1 week ago by  Duo_Liang.
    Participant
    nehme
    Senior Member
    Member since: 23.07.2018
    Number of posts: 101

    Score

    0

    Hello,

    Thanks for the info. But how I will do it by using .Net SDK? C#

    Thanks

    Keymaster
    Duo_Liang
    Guru
    Member since: 14.06.2018
    Number of posts: 398

    Score

    0

    Hi nehme,

    Below is the C# snippet for you:

    String packageId = "zS4Ja624YHq3XZMgEWTURNP_dfk=";
    DocumentPackage package = PackageBuilder.NewPackageNamed("test from template")
                    .WithSigner(SignerBuilder.NewSignerWithEmail("signer11@mailinator.com").WithFirstName("1.firstname").WithLastName("1.lastname").WithCustomId("fd651a15-b2f4-4937-bd44-f96e3a60f076").Build())
                    .WithSigner(SignerBuilder.NewSignerWithEmail("signer22@mailinator.com").WithFirstName("2.firstname").WithLastName("2.lastname").WithCustomId("e399a1bf-1417-49a0-b4e4-18088f4692ff").Build())
                    .Build();
    PackageId newPackageId = eslClient.CreatePackageFromTemplate(new PackageId(packageId),package);

    You just need to create a new package object with signers you want to replace the placeholders and other infos you want to replace from the template and call CreatePackageFromTemplate()function. The request payload is almost the same as above JSON.

    Duo


    Duo Liang
    OneSpan Junior Technical Evangelist
    Participant
    nehme
    Senior Member
    Member since: 23.07.2018
    Number of posts: 101

    Score

    0

    Thanks for all the help.

    How did you get the CustomID??

    WithCustomId(“fd651a15-b2f4-4937-bd44-f96e3a60f076”)

    ?

    Thanks

    Keymaster
    Duo_Liang
    Guru
    Member since: 14.06.2018
    Number of posts: 398
    Approved answer

    Score

    0

    Hi nehme,

    You can use following two lines to retrieve placeholder’s ID:

    DocumentPackage package_old = eslClient.GetPackage(new PackageId(packageId));
    string id1 = package_old.Placeholders.ElementAt(0).Id;
    string id2 = package_old.Placeholders.ElementAt(1).Id;
    
    or
    
    string id1 = "";
    string id2 = "";
    foreach (var signer in package_old.Placeholders) {
        if (signer.PlaceholderName == "Signer1") {
                         id1 = signer.Id;
                    }
       else if (signer.PlaceholderName == "Signer2")
                    {
                         id2 = signer.Id;
                    }
                }
    

    If you create your template through WebUI, the only thing to locate the specific signer is the placeHolderName I believe. So if you can, still suggest to use SDK to create the template so that you can assign your placeholder ID already.
    Duo


    Duo Liang
    OneSpan Junior Technical Evangelist
    • This reply was modified 2 months, 1 week ago by  Duo_Liang.
    Participant
    nehme
    Senior Member
    Member since: 23.07.2018
    Number of posts: 101

    Score

    0

    Thanks for all the support. This is what I wanted and solve my issue. 🙂

You must be logged in to reply to this topic.