0

Goal

Hey, I have a scenario in which I want to create an envelope based on a template, and I want to give our users the ability to change the name & email of the recipients specified in the template.

This is how my code currently looks like

            const compositeTemplate = docusign.CompositeTemplate.constructFromObject({
                serverTemplates: [
                    // @ts-expect-error exists
                    docusign.ServerTemplate.constructFromObject({
                        sequence: 1,
                        templateId,
                    })
                ],
                inlineTemplates: [
                    // @ts-expect-error exists
                    docusign.InlineTemplate.constructFromObject({
                        templateId,
                        sequence: 2,
                        recipients: this.serializeUpdateRecipients(signers),
                    })
                ]
            });

            // @ts-expect-error exists
            const envelopeDefinition = docusign.EnvelopeDefinition.constructFromObject({
                status: "sent",
                compositeTemplates: [compositeTemplate],
            })

            const envelopesApi = new docusign.EnvelopesApi(this.client);
            const envelope = await envelopesApi.createEnvelope(this.userInfo.accounts[0].accountId, {
                envelopeDefinition,
            })

Problem

Everything works fine except that the envelope is sent to both recipients, the original one and the edited one.

I made sure to only edit the recipient's (signer) email or name, and not the recipientId.

this is how looks like

    private serializeUpdateRecipients(signers: Signer[]) {
        // @ts-expect-error Docusign @types are not up to date
        const recipients = new docusign.Recipients();
        recipients.signers = signers.map(({ name, email, tabs, roleName, recipientId, routingOrder }) => (
            // @ts-expect-error Docusign @types are not up to date
            new docusign.Signer.constructFromObject({
                email,
                name,
                roleName,
                recipientId,
                routingOrder,
                tabs,
            })
        ));
        return recipients;
    }

I copied the recipient info from what's returned in the template.

Previous attempts

Also, before trying the Composite Template approach, I was using the standard approach of sending an envelope based on a template, but adding editing the recipients inline in the envelope still caused the duplication issue, which is why I tried the alternative Composite template approach.

[Edit]

snippet in docs titled: Merging duplicate recipients

https://developers.docusign.com/docs/esign-rest-api/esign101/concepts/templates/composite/

Here's a snippet in the DocuSign docs regarding merging duplicate recipients.

It says:

You can automatically merge these duplicate recipients by making sure that each of these duplicate recipients has the same email, user name, and routing order

Does that mean that I cannot edit the base template's recipient's email at all? Maybe there's another approach outside of composite templating?

Thanks for reading.

1 Answer 1

0

You're specifying the server template twice.

Here's a live example you can try.

Try this envelope request:

         {
            status: "sent",
            compositeTemplates: [
                {
                    compositeTemplateId: "1",
                    serverTemplates: [
                        {
                            sequence: "1",
                            templateId: templateId
                        }
                    ],
                    inlineTemplates: [
                        {
                            sequence: "1",
                            recipients: {
                                signers: [
                                    {
                                        email: email,
                                        name: name,
                                        roleName: "Signer1",
                                        recipientId: "1",
                                    }
                                ]
                            }
                        }
                    ]
                }
            ]
        };
3
  • Thanks, but that didn't work. The only thing that worked so far is to remove the email and name on DocuSign's side. But we want to support a default name/email that are changeable Commented Nov 3, 2023 at 15:47
  • Changeable how? Via your code (your app)? Via the DocuSign web app?
    – Larry K
    Commented Nov 4, 2023 at 19:43
  • Via my app. We offer a 3rd party integration with DocuSign. Commented Nov 14, 2023 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.