Skip to main content
Question

EnvelopeViews: createSender: Preview - Does it not work with Docusign JS

  • January 15, 2025
  • 2 replies
  • 38 views

z3nkarun
Newcomer
Forum|alt.badge.img+2

I see this documentation of docusign JS embedding to get the event just for Signing view. Is this not relevant for when we create Preview urls of Envelope? 

I have created and envelope and opening up a preview within an iframe. I wanted to catch events directly in my parent window but doesnt seem to be working. 

2 replies

Forum|alt.badge.img+6
  • Docusign Employee
  • 60 replies
  • January 16, 2025

Hello ​@z3nkarun,

To use focused view with i-frames you need to create your view, just like the article said, but also, you need to generate a sender view, and embed the view in the i-Frame.

 

You can check how to create your view here:

async function createSenderView(accessToken, accountId, envelopeId) {
  const docusign = require('docusign-esign');
  const apiClient = new docusign.ApiClient();
  apiClient.setBasePath('https://demo.docusign.net/restapi');
  apiClient.addDefaultHeader('Authorization', `Bearer ${accessToken}`);

  const envelopesApi = new docusign.EnvelopesApi(apiClient);
  const viewRequest = new docusign.ReturnUrlRequest();
  viewRequest.returnUrl = 'https://application.test.com/return';

  try {
    const result = await envelopesApi.createSenderView(accountId, envelopeId, { returnUrlRequest: viewRequest });
    return result.url;
  } catch (error) {
    console.error('Error creating sender view:', error);
    throw error;
  }
}
 

And you can check how to embed an URL here:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>DocuSign Sender View</title>
</head>
<body>
  <iframe id="docusign-sender-view" width="100%" height="100%" frameborder="0"></iframe>

  <script>
    async function embedSenderView() {
      const senderViewUrl = 'YOUR_SENDER_VIEW_URL'; // Replace with your dynamically generated URL
      const iframe = document.getElementById('docusign-sender-view');
      iframe.src = senderViewUrl;
    }

    embedSenderView();
  </script>
</body>
</html>


z3nkarun
Newcomer
Forum|alt.badge.img+2
  • Author
  • Newcomer
  • 2 replies
  • January 16, 2025

Hi Eduardo, 

Thanks for your reply.  I would like to add, I have done exactly as you mentioned of embedding senderViewUrl inside an iframe; but when creating SenderView - I can pass redirectUri in the api, right? now the issue I had was that redirectUri domain cannot be opened in an embedded iframe unfortunately. So I am unable to capture the event in the redirectUri and utilize the above solution. 

Therefore I raised - if it were possible to, perhaps,  publish the user’s events to the parent iframe for Embedded sender view (similar to using docusign-js in signing view