public void CreateEnvelopeFromTemplatesAndFormsTest() { // Configure the envelope information DocuSignWeb.EnvelopeInformation envelopeInfo = new DocuSignWeb.EnvelopeInformation(); envelopeInfo.AccountId = _accountId; envelopeInfo.EmailBlurb = "testing docusign creation services"; envelopeInfo.Subject = "create envelope from templates and forms test"; DocuSignWeb.CompositeTemplate template = new DocuSignWeb.CompositeTemplate(); DocuSignWeb.Recipient recipient1 = new DocuSignWeb.Recipient(); recipient1.UserName = "******"; // TODO: replace the email string with an actual email recipient1.Email = "test email one"; recipient1.Type = DocuSignWeb.RecipientTypeCode.Signer; recipient1.RequireIDLookup = false; recipient1.RequireIDLookupSpecified = true; recipient1.RoutingOrder = 1; recipient1.RoutingOrderSpecified = true; recipient1.RoleName = "One"; recipient1.ID = "1"; DocuSignWeb.Recipient recipient2 = new DocuSignWeb.Recipient(); recipient2.UserName = "******"; // TODO: replace the email string with an actual email recipient2.Email = "test email two"; recipient2.Type = DocuSignWeb.RecipientTypeCode.Signer; recipient2.RequireIDLookup = false; recipient2.RequireIDLookupSpecified = true; recipient2.RoutingOrder = 2; recipient2.RoutingOrderSpecified = true; recipient2.RoleName = "Two"; recipient2.ID = "2"; DocuSignWeb.Recipient[] signers = { recipient1, recipient2 }; // Configure the inline templates DocuSignWeb.InlineTemplate inlineTemplate = new DocuSignWeb.InlineTemplate(); inlineTemplate.Sequence = "1"; inlineTemplate.Envelope = new DocuSignWeb.Envelope(); inlineTemplate.Envelope.Recipients = signers; inlineTemplate.Envelope.AccountId = _accountId; // This tab matches the DateSigned tab assigned to recipient one DocuSignWeb.Tab tab1 = new DocuSignWeb.Tab(); tab1.RecipientID = "1"; tab1.TabLabel = "DocuSignDateSignedOne"; tab1.Type = DocuSignWeb.TabTypeCode.DateSigned; // This tab matches the SignHere tabs assigned to recipient two DocuSignWeb.Tab tab2 = new DocuSignWeb.Tab(); tab2.RecipientID = "2"; tab2.TabLabel = "SignTwo\\*"; tab2.Type = DocuSignWeb.TabTypeCode.SignHere; // This tab matches the SignHere tabs assigned to recipient one DocuSignWeb.Tab tab3 = new DocuSignWeb.Tab(); tab3.RecipientID = "1"; tab3.TabLabel = "SignOne\\*"; tab3.Type = DocuSignWeb.TabTypeCode.SignHere; // This tab matches the DateSigned tab assigned to recipient two DocuSignWeb.Tab tab4 = new DocuSignWeb.Tab(); tab4.RecipientID = "2"; tab4.TabLabel = "DocuSignDateSignedTwo"; tab4.Type = DocuSignWeb.TabTypeCode.DateSigned; // This tab matches nothing -- but that's okay! // It will just get discarded DocuSignWeb.Tab tab5 = new DocuSignWeb.Tab(); tab5.RecipientID = "1"; tab5.TabLabel = "asdf"; tab5.Type = DocuSignWeb.TabTypeCode.FullName; inlineTemplate.Envelope.Tabs = new DocuSignWeb.Tab[] { tab1, tab2, tab3, tab4, tab5 }; template.InlineTemplates = new DocuSignWeb.InlineTemplate[] { inlineTemplate }; // Configure the document template.Document = new DocuSignWeb.Document(); template.Document.ID = "1"; template.Document.Name = "Form Document"; template.Document.PDFBytes = Resource.LoremIpsum; template.Document.TransformPdfFields = true; template.Document.FileExtension = "pdf"; // Create draft with all the composite template information DocuSignWeb.EnvelopeStatus status = _apiClient.CreateEnvelopeFromTemplatesAndForms(envelopeInfo, new DocuSignWeb.CompositeTemplate[] { template/*, template2*/ }, false); // Confirm that the envelope has been assigned an ID Assert.IsNotNullOrEmpty(status.EnvelopeID); // Confirm that we have the correct number of tabs for each recipient Assert.AreEqual(3, status.RecipientStatuses[0].TabStatuses.Length); Assert.AreEqual(3, status.RecipientStatuses[1].TabStatuses.Length); Console.WriteLine("Envelope Id is {0}", status.EnvelopeID); }
/// <summary> /// Create a basic envelope with documents and tabs in preparation for sending /// </summary> /// <param name="envelope">already created envelope</param> /// <returns>updated envelope</returns> internal static DocuSignWeb.Envelope CreateEnvelopeWithDocumentAndTabs(DocuSignWeb.Envelope envelope) { envelope.Documents = new DocuSignWeb.Document[1]; DocuSignWeb.Document doc = new DocuSignWeb.Document(); doc.ID = "1"; doc.Name = "Picture PDF"; doc.PDFBytes = Resource.picturePdf; Assert.IsNotNull(doc.PDFBytes); envelope.Documents[0] = doc; DocuSignWeb.Tab tab = new DocuSignWeb.Tab(); tab.DocumentID = "1"; tab.RecipientID = "1"; tab.Type = DocuSignWeb.TabTypeCode.SignHere; tab.PageNumber = "1"; tab.XPosition = "100"; tab.YPosition = "100"; envelope.Tabs = new DocuSignWeb.Tab[1]; envelope.Tabs[0] = tab; return envelope; }