Skip to main content
Newcomer
January 20, 2025
Solved

Creating Envelopes with NextJs

  • January 20, 2025
  • 2 replies
  • 276 views

I’m using the DocuSign Node.js package to create an envelope in my Next.js application. I have imported the necessary classes from DocuSign as: 

 

import { ApiClient, EnvelopesApi, EnvelopeDefinition, TemplateRole } from 'docusign-esign';

 

But, it seems like I am unable to use the “EnvelopeDefinition” method. I have it as: 

 

// Prepare the envelope details

const envelopeDefinition = new EnvelopeDefinition();

 

The issue I’m having is that I get the message; “'EnvelopeDefinition' only refers to a type, but is being used as a value here.” when try to initialize the envelope definition.

 

What am I doing wrong? Can someone please asssist?

 

 

 

 

Best answer by Sai.Dandamudi

Hello Team

The issue is likely due to how TypeScript handles type-only imports versus actual value imports. 

const envelopeDefinition = { / initialize your envelope details here as an object / }; Or,  may be as below:

 

const envelopeDefinition = {
  emailSubject: "Please sign this document",
  templateId: "your-template-id",
  templateRoles: [
    {
      email: "recipient@example.com",
      name: "Recipient Name",
      roleName: "RoleName",
    },
  ],
  status: "sent",
};

This approach works as EnvelopeDefinition in DocuSign SDK might not be a JavaScript constructor. Instead, the SDK uses plain objects for configuration.

Please try and if you still see issues then please log a case with DS Support attaching logs  https://support.docusign.com/guides/ndse-user-guide-api-request-logging & we will investigate from there.

 

Thankyou

Sai

 

2 replies

Docusign Employee
January 21, 2025

Hello Team

The issue is likely due to how TypeScript handles type-only imports versus actual value imports. 

const envelopeDefinition = { / initialize your envelope details here as an object / }; Or,  may be as below:

 

const envelopeDefinition = {
  emailSubject: "Please sign this document",
  templateId: "your-template-id",
  templateRoles: [
    {
      email: "recipient@example.com",
      name: "Recipient Name",
      roleName: "RoleName",
    },
  ],
  status: "sent",
};

This approach works as EnvelopeDefinition in DocuSign SDK might not be a JavaScript constructor. Instead, the SDK uses plain objects for configuration.

Please try and if you still see issues then please log a case with DS Support attaching logs  https://support.docusign.com/guides/ndse-user-guide-api-request-logging & we will investigate from there.

 

Thankyou

Sai

 

yattishNewcomerAuthor
Newcomer
January 22, 2025

Hello Sai

 

Thank you for your response to me enquiry. I’ve managed to work around the issue by using the RESTAPI instead. I found that I was encountering numerous issues when I used the DocuSign SDK. I’ve implemented a similar structure as you’ve proposed in your solution and my application is now working as expected.

 

Thanks your for your assistance.

 

Kind regards,

Yattish