Create Package from Template
Thursday, October 6, 2016 at 08:10amHi,
I have a requirement where I have a template with placeholders for signers. I need to create a new package from this template and replace the signer Placeholders with actual signer info. I referred to the CreatePackageFromTemplateWithReplacingPlaceholderExample but the problem I face is that instead of replacing the existing placeholder it creates a new signer for the package.
My requirement will have 2 or more signers so I have to loop through a MAP to get all the signer info.
Here is a sample of my code:
public class CreatePackageFromTemplateController { Void PackageFromTemplate(MaptemplateData) { SignerBuilder signer; String successMessage; String tempIdString = templateData.getAt("templateId"); PackageId tempPackageId = new PackageId(tempIdString); EslClient dssEslClient(/*this will have my URL and API key*/); /*Create the Package.*/ PackageBuilder packageFromTemplate = newPackageNamed(templateData.packageName); packageFromTemplate.withSenderInfo(SenderInfoBuilder.newSenderInfo(templateData.senderEmail)); def signersArray = templateData.signers; for (int j = 0; j signersArray.size(); j++) { signer = SignerBuilder.newSignerWithEmail(signersArray[j].getAt("signerEmail")) .withFirstName(signersArray[j].getAt("signerFirstName")) .withLastName(signersArray[j].getAt("signerLastName")) .replacing(new Placeholder(signersArray[j].getAt("placeHolder"))); if ((templateData.containsKey(signersArray[j].getAt("noteToSigner")))||(StringUtils.isNotEmpty(signersArray[j].getAt("noteToSigner")))) { signer.withEmailMessage(signersArray[j].getAt("noteToSigner")); } packageFromTemplate.withSigner(signer); } try { /*The package attribute is set to the organization name using withAttributes() method*/ DocumentPackage completePackage = packageFromTemplate .withSettings(DocumentPackageSettingsBuilder.newDocumentPackageSettings().withInPerson()) .withAttributes(newDocumentPackageAttributes() .withAttribute("orgName", templateData.orgName) .build()) .build(); PackageId packageId = dssEslClient.getTemplateService().createPackageFromTemplate(tempPackageId, completePackage); successMessage = "Package created and available in the draft folder." } catch (Exception e) { printStackTrace(); } } }
Reply to: Create Package from Template
Thursday, October 6, 2016 at 08:48amReply to: Create Package from Template
Thursday, October 6, 2016 at 08:50amReply to: Create Package from Template
Thursday, October 6, 2016 at 09:03amReply to: Create Package from Template
Thursday, October 6, 2016 at 09:29amReply to: Create Package from Template
Thursday, October 6, 2016 at 09:30amReply to: Create Package from Template
Wednesday, October 26, 2016 at 11:29amReply to: Create Package from Template
Thursday, October 27, 2016 at 04:14amReply to: Create Package from Template
Thursday, October 27, 2016 at 06:42amReply to: Create Package from Template
Friday, October 28, 2016 at 03:50amReply to: Create Package from Template
Friday, October 28, 2016 at 04:36am