I am using the C# DocuSign library and I am sending 2 documents in the envelope.
I am adding 2 recipients.
The first recipient must sign document 1 so the SignHere class has DocumentId set to 1. The second recipient must sign document 2 so the SignHere class has DocumentId set to 2.
What happens is that both recipients get asked to sign document 1 and document 2 and the signatures overwrite each other.
So the DocumentId in the SignHere class is being ignored. This seems like a bug.
It seems like the anchor string is the only thing really controlling who signs what document and both documents are going to have anchor strings that are the same. This is because the documents will have been pre-built with anchor strings like <<<signhere:1>>>
I have edited this to show my code:
public string SendDocument(
DocuSignDocument[] Documents,
DocuSignRecipient[] Recipients,
DocuSignSignature[] Signatures,
string EmailSubject = null)
{
string AccessToken = GetAccessToken();
List<Document> EnvelopeDocuments = new List<Document>();
int Index = 0;
foreach (DocuSignDocument Doc in Documents)
{
Document Document = new Document
{
DocumentBase64 = Convert.ToBase64String(FileToBytes(Doc.FileName)),
Name = Doc.DocumentName,
FileExtension = Path.GetExtension(Doc.FileName).TrimStart('.'),
DocumentId = (Index + 1).ToString()
};
EnvelopeDocuments.Add(Document);
Index++;
}
List<Signer> Signers = new List<Signer>();
List<SignHere> SignTabs;
Index = 0;
foreach (DocuSignRecipient Recipient in Recipients)
{
Signer Signer = new Signer()
{
Email = Recipient.EmailAddress,
Name = Recipient.Name,
RecipientId = (Index + 1).ToString(),
RoutingOrder = (Index + 1).ToString()
//RoutingOrder = "1"
};
SignTabs = new List<SignHere>();
// Set the signatures needed for this recipient
foreach (DocuSignSignature Sig in Signatures)
{
if (Sig.DocumentIndex < 0 || Sig.DocumentIndex > Documents.Length - 1)
throw new Exception("Invalid signature DocumentIndex");
if (Sig.RecipientIndex < 0 || Sig.RecipientIndex > Recipients.Length - 1)
throw new Exception("Invalid signature RecipientIndex");
if (Sig.RecipientIndex == Index)
{
// Signature is for this recipient
SignHere SignHere = new SignHere()
{
// It seems DocumentId here is ignored because this recipient still gets asked to sign both documents
DocumentId = (Sig.DocumentIndex + 1).ToString(),
RecipientId = (Sig.RecipientIndex + 1).ToString(),
TabLabel = "Sign here for " + Recipient.Name,
AnchorString = "<<<signhere:" + (Sig.DocumentSignatureIndex + 1) + ">>>"
};
SignTabs.Add(SignHere);
}
}
Signer.Tabs = new Tabs() { SignHereTabs = SignTabs };
Signers.Add(Signer);
Index++;
}
if (EmailSubject == null)
EmailSubject = "Please sign the document";
EnvelopeDefinition Envelope = new EnvelopeDefinition
{
EmailSubject = EmailSubject,
Documents = EnvelopeDocuments,
Recipients = new Recipients { Signers = Signers },
Status = "sent"
};
ApiClient Client = new ApiClient(ApiAddress);
Client.Configuration.AddDefaultHeader("Authorization", "Bearer " + AccessToken);
EnvelopesApi EnvelopesApi = new EnvelopesApi(Client.Configuration);
EnvelopeSummary Results = EnvelopesApi.CreateEnvelope(_AccountId, Envelope);
return Results.EnvelopeId;