I'm using the DocuSign.eSign library from https://github.com/docusign/docuSign-csharp-client
I've created an EnvelopeDefinition:
var envDef = new EnvelopeDefinition()
{
CustomFields = new CustomFields()
{
TextCustomFields = new List<TextCustomField>()
{
new TextCustomField()
{
FieldId = "d9d584f6-0a3a-40df-b94f-407c1a90c87d",
Name = "A.LoanNumber",
Required = "true",
Show = "true",
Value = "1234567890",
},
},
},
EmailBlurb = "Don't panic! This is only a template test.",
EmailSubject = "Template Test...",
Status = "sent",
TemplateId = "458407ac-f0a0-44e6-a60b-5126e2d0a8cf",
TemplateRoles = new List<TemplateRole>()
{
new TemplateRole()
{
AccessCode = "1234",
Email = "jjeppson#example.com",
Name = "Josh Jeppson",
RoleName = "Borrower.1",
},
},
};
But no matter what combination of values I have used for properties of the TextCustomField, the default value for A.LoanNumber, "Loan Number", is output in the resulting document.
The envelope sends correctly but none of the fields (only one shown above) have been inserted/replaced in the document.
Using the specified library, how do I override the default values for the custom fields?
Related
I'm trying to create a workflow where a user can do a bulk send through docusign within my application. They would select the clients they want to send forms to for a signature, be presented with a sender view to specify what fields they require, send it off, then have it post back to my application in order to generate emails for embedded signing. However, currently, it doesn't return back to my application after the user has sent off the bulk request despite the return url request being set. Is this currently not possible with a bulk send request?
The following is just some code to generate the sender view url:
// Create envelope definition
var envelopeDefinition = new EnvelopeDefinition
{
EmailSubject = documentDesc,
Documents = new List<Document>(),
Recipients = new Recipients { Signers = new List<Signer> {
new Signer
{
Name = "Multi Bulk Recipient::signer",
Email = "multiBulkRecipients-signer#docusign.com",
RoleName = "signer",
RoutingOrder = "1",
Status = "sent",
DeliveryMethod = "Email",
RecipientId = "1",
RecipientType = "signer"
}
} },
CustomFields = new CustomFields()
{
TextCustomFields = new List<TextCustomField>()
{
new TextCustomField() {Name = "Client", Value = _config.DatabaseName},
new TextCustomField() {Name = "Server", Value = _config.DatabaseServer},
new TextCustomField() {Name = "DocId", Value = documentId.ToString()}
}
},
EnvelopeIdStamping = "true",
};
// Read a file from disk to use as a document.
byte[] fileBytes = File.ReadAllBytes("test.pdf");
// Add a document to the envelope
Document doc = new Document();
doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
doc.Name = "TestFile.pdf";
doc.DocumentId = "1";
envDef.Documents = new List<Document>();
envDef.Documents.Add(doc);
// Add each recipient and add them to the envelope definition
var recipients = new List<BulkSendingCopyRecipient>();
var recipients = new List<BulkSendingCopyRecipient> {
new BulkSendingCopyRecipient
{
Name = "Bob Ross",
Email = "bobross#happymistakes.com",
ClientUserId = "1234",
CustomFields = new List<string>()
{
"A custom field for internal use"
},
RoleName = "signer"
},
new BulkSendingCopyRecipient
{
Name = "Fred Rogers",
Email = "mrrogers#neighborhood.com",
ClientUserId = "5678",
CustomFields = new List<string>()
{
"Another custom field for internal use"
},
RoleName = "signer"
}
};
var bulkSendingCopy = new BulkSendingCopy
{
Recipients = recipients
};
var bulkCopies = new List<BulkSendingCopy>
{
bulkSendingCopy
};
var bulkSendingList = new BulkSendingList
{
BulkCopies = bulkCopies
};
bulkSendingList.Name = "A document name";
envelopeDefinition.Status = "created";
var envelopesApi = new EnvelopesApi(config);
var bulkEnvelopesApi = new BulkEnvelopesApi();
var createBulkListResult = bulkEnvelopesApi.CreateBulkSendList(AccountId, bulkSendingList);
envelopeDefinition.CustomFields.TextCustomFields.Add(
new TextCustomField
{
Name = "mailingListId",
Required = "false",
Show = "false",
Value = createBulkListResult.ListId //Adding the BULK_LIST_ID as an Envelope Custom Field
}
);
var envelopeSummary = envelopesApi.CreateEnvelope(AccountId, envelopeDefinition);
var options = new ReturnUrlRequest
{
ReturnUrl = HttpContext.Current.Request.Url.Scheme + "://" +
HttpContext.Current.Request.Url.Authority +
HttpContext.Current.Request.ApplicationPath +
"/SIP/ConfirmTagSendAndPublish.aspx?idockey=" + documentId
};
var senderView = envelopesApi.CreateSenderView(AccountId, envelopeSummary.EnvelopeId, options);
var senderViewInfo = new string[2];
senderViewInfo[0] = senderView.Url;
senderViewInfo[1] = envelopeSummary.EnvelopeId;
return senderViewInfo;
When the sender view comes up and you hit send it just takes me to the Sent tab in docusign
What I see after send
So in order for you to do the scenario you're asking to do, you will have to take a slightly different approach:
Generate a regular envelope in draft mode with the things you need.
Have user interact with it in embedded sending experience.
Generate a bulk using the CreateBulkList() method based on the envelope from #2 and the users you add like in your code.
(to do #3 you may need to copy custom fields etc. from the initial envelope to the one used for custom fields)
I am trying to implement the document visibility of docuSign.suppose i have two document(Document A and Document B) and I have two CC person (Person A and Person B)
and i am trying to hide the document from CC person (who receive a copy of document). Document B from Person A and Document A from Person B.
but when i try this from DocuSign portal it is working fine but when i implement the code for this then the visibility setting of document is not working.
public void docusign(string path, string recipientName, string recipientEmail, string EnvelopeId)
{
ApiClient apiClient = new ApiClient("https://demo.docusign.net/restapi");
Configuration.Default.ApiClient = apiClient;
//Verify Account Details
string accountId = loginApi(credential.UserName, credential.Password);
// Read a file from disk to use as a document.
byte[] fileBytes = System.IO.File.ReadAllBytes(path);
byte[] fileBytes1 = System.IO.File.ReadAllBytes(#"Path");
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.EmailSubject = "Please sign this doc";
//Here i am adding the document
Document doc = new Document();
doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
doc.Name = Path.GetFileName(path);
doc.DocumentId = "1";
doc.TransformPdfFields = "true";
Document doc1 = new Document();
doc1.DocumentBase64 = System.Convert.ToBase64String(fileBytes1);
doc1.Name = "Test 2-converted -converted.pdf";// Path.GetFileName(path);
doc1.DocumentId = "2";
//Adding CC person
List<CarbonCopy> oo = new List<CarbonCopy>();
oo.Add(new CarbonCopy
{
RecipientId = "1",
RoutingOrder = "1",
Name = "darpan",
Email = "xyz1#gmail.com",
DocumentVisibility = new List<DocumentVisibility>() { new DocumentVisibility { Visible = "false", DocumentId = "2", RecipientId = "1" } },
});
oo.Add(new CarbonCopy
{
RecipientId = "2",
RoutingOrder = "2",
Name = "mohini",
Email = "xyz2#gmail.com",
DocumentVisibility= new List<DocumentVisibility>() { new DocumentVisibility { Visible = "false", DocumentId = "1", RecipientId = "2" } },
});
envDef.Recipients = new DocuSign.eSign.Model.Recipients();
envDef.Recipients.CarbonCopies = oo;
envDef.Status = "Sent";
// |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
EnvelopesApi envelopesApi = new EnvelopesApi();
EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);
you need to add this to your code:
envDef.EnforceSignerVisibilty = "true";
I found the issue. It because I am not listing all document in document visibility list.
Like I have two document in envelop and while adding document visibility list.
I am only adding document that need visibility to false.
Document visibility list should have all the document in list with visibility setting.
What I am doing
DocumentVisibility = new List<DocumentVisibility>() { new DocumentVisibility { Visible = "false", DocumentId = "2", RecipientId = "1"}}
Correct way is
DocumentVisibility = new List<DocumentVisibility>() { new DocumentVisibility { Visible = "false", DocumentId = "2", RecipientId = "1" },new DocumentVisibility { Visible = "true", DocumentId = "1", RecipientId = "1" }}
I have a field in my template that has validation for numbers only enabled. If I were to remove this validation, it would prefill the field on the document. Enabling it will not prefill that field. Is there a way to prefill validated fields?
I am using the latest version of DocuSign nuget package.
This is my code to prefill the data. It only works on non-validated fields.
var accountNumber = new Text
{
TabLabel = "AccountNumber",
Value = form.AccNo,
};
var tabList = new List<Text> {bankName, accountNumber, accountName};
formInfo.Tabs = new Tabs();
formInfo.Tabs.TextTabs = tabList;
envelope.TemplateRoles = new List<TemplateRole> { formInfo };
envelope.Status = "sent";
var summary = envelopesApi.CreateEnvelope(AccountID, envelope);
When you enable Validation for a field, it actually changes the field type. Instead of a Text, that tag will now be a Number:
var accountNumber = new DocuSign.eSign.Model.Number
{
TabLabel = "AccountNumber",
Value = form.AccNo
};
and it will need to go into a different Tabs list under your Recipient:
signer.Tabs = new Tabs
{
TextTabs = new List<DocuSign.eSign.Model.Text>
{
bankName,
accountName
},
NumberTabs = new List<DocuSign.eSign.Model.Number>
{
accountNumber
}
};
Other validation options can also change the tab type. Depending on what you're doing, you could be working with EmailTabs, DateTabs, SsnTabs or ZipTabs.
I have a template in Docusign that I need to send to joe#acme.com
However Joe is responsible for managing 10 clients and instead of me sending Joe 10 separate envelopes for him to sign I want to send Joe 1 envelope with 10 documents and Joe needs to sign all 10 document in the envelope. The documents are identical except for the different data filled in the text field of the template
I am using the C# SDK provided by Docusign and I can send one document in an envelope using EnvelopeDefinition class and TemplateRole class but am lost as to how to create 10 documents in an envelope
The following recipe does it but it is in python and uses the REST API with which I am not sure how to translate to the C# SDK equivalent
https://www.docusign.com/developer-center/recipes/send-multiple-docs
You can use compositeTemplates and reuse the same server template multiple times in the envelope. The below code uses the same server Template and repeats it 10 times in the envelope. See full example here
public void CreateEnvelope()
{
var envDef = new EnvelopeDefinition()
{
EmailSubject = "Envelope with multiple documents",
Status = "sent",
CompositeTemplates = new List<CompositeTemplate>()
};
for (int docNumber = 1; docNumber <= 10; docNumber++)
{
var compostiteTemplate = BuildCompositeTemplate(docNumber.ToString());
envDef.CompositeTemplates.Add(compostiteTemplate);
}
EnvelopesApi envelopesApi = new EnvelopesApi();
EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);
Console.WriteLine(envelopeSummary);
}
public CompositeTemplate BuildCompositeTemplate(string docNumber)
{
string serverTemplateId = "";//Add your server template ID here
return new CompositeTemplate()
{
ServerTemplates = new List<ServerTemplate>()
{
new ServerTemplate()
{
TemplateId = serverTemplateId,
Sequence = docNumber
}
},
InlineTemplates = new List<InlineTemplate>()
{
new InlineTemplate()
{
Sequence = docNumber,
Recipients = new Recipients()
{
Signers = new List<Signer>()
{
new Signer()
{
Email = "Janedoe#acme.com",
Name = "Jane Doe",
RecipientId = "1",
RoleName = "Signer1",
Tabs = new Tabs()
{
TextTabs = new List<Text>()
{
new Text()
{
DocumentId = docNumber,
PageNumber = "1",
XPosition = "100",
YPosition = "100",
Width = 120,
Value = "Some Tab Value " + docNumber
}
}
}
}
}
}
}
}
}
}
There is the property Documents in the class EnvelopeDefinition, where you can add multiply documents.
I use the REST API Explorer from DocuSign when I want to check how to implement a feature.
enDef = new EnvelopeDefinition();
doc = new Document();
doc.DocumentBase64 = System.Convert.ToBase64String(System.IO.File.ReadAllBytes(filename));
doc.Name = DocName;
doc.DocumentId = "1"; // increment this
enDef.Documents = new List<Document>();
enDef.Documents.Add(doc);
Added
For multiply template roles also exists a property called TemplateRoles in the EnvelopeDefinition. There you can add more than one.
tempRole = new TemplateRole();
tempRole.Name = Rolename;
enDef.TemplateRoles = new List<TemplateRole>();
enDef.TemplateRoles.Add(tempRole);`
The requirement which I have regarding docusign is I need to implement Signer Attachment and that same scenario is mentioned at [https://github.com/docusign/docusign-soap-sdk/wiki/Code-Walkthrough-_-Signer-Attachments]
But I am not sure how do I achieve with code in C#. As not sure how do I attach it to Envelope?
I want to send someone a contract letter to sign and also request them attach few docs and when all of that is completed , those docs should be sent to my email.
Anyone knows if I can achieve it with docusign?
The previous entry is not bad... I got it working eventually. But this code below is solid, in production, and works great! It also uses anchor strings.
EnvelopeDefinition env = new EnvelopeDefinition();
env.EmailSubject = "Please sign this document set";
Document doc4 = new Document
{
DocumentBase64 = doc4PdfBytes,
Name = "Voided Check Attachment", // can be different from actual file name
FileExtension = "pdf",
DocumentId = "4"
};
env.Documents = new List<Document> { doc4 };
SignerAttachment signAttachDoc = new SignerAttachment
{
TabLabel = "Attach your voided check",
DocumentId = "1",
TabId = "1",
PageNumber = "1",
AnchorString = "/at1/",
AnchorUnits = "pixels",
AnchorXOffset = "0",
AnchorYOffset = "0",
AnchorIgnoreIfNotPresent = "false",
};
Tabs signer1Tabs = new Tabs
{
SignerAttachmentTabs = new List<SignerAttachment> { signAttachDoc }
};
signer1.Tabs = signer1Tabs;
Recipients recipients1 = new Recipients
{
Signers = new List<Signer> { signer1 }
};
env.Recipients = recipients1;
Here is how we can do it while using C# SDK
create a signer object
Signer signer = new Signer();
signer.Name = recipientName;
signer.Email = recipientEmail;
signer.RecipientId = "1";
then create attachment tabs
signer.Tabs.SignerAttachmentTabs = new List<SignerAttachment>();
after which we need an attachment to add to it
SignerAttachment signDoc = new SignerAttachment();
signDoc.TabLabel = "Attach your Other Doc";
signDoc.DocumentId = "1";
signDoc.TabId = "1";
signDoc.PageNumber = "1";
And finally we add it to the tabs
signer.Tabs.SignerAttachmentTabs.Add(signDoc);