嵌入式DocuSign签名:iframe传参问题及跳出iframe返回参数咨询
Hey there! Let’s tackle your two DocuSign embedded signing questions step by step—I’ve dealt with similar headaches before, so I think I can help!
1. 返回参数情况(嵌入式签名跳出iframe时)
When users finish, cancel, or abandon an embedded signing session and the flow exits the iframe, DocuSign passes back key parameters in one of two ways, depending on your return URL setup:
- Redirect-based return: When DocuSign redirects to your specified
returnUrl, it appends these critical query parameters automatically:envelopeId: The unique ID for the envelope (matches your "envelope" parameter)powerFormId: The ID of the PowerForm used for the signing flow (your "PF" parameter)recipientId: The ID of the signer (your "r ID" parameter)event: The type of signing event (e.g.,signing_complete,declined,cancelled)- Bonus: If there was an error during signing, you’ll also get
errorCodeanderrorMessageparameters.
- JavaScript callback (for in-iframe handling): If you’re using DocuSign’s JS SDK, you can set up a callback that triggers when signing completes without leaving the iframe. The callback will receive an event object containing all the relevant IDs:
Note that the "exit iframe" scenario usually uses the redirect method, so focus on that if your flow is designed to leave the iframe.docusign.signingCompleted(function(event) { console.log("Envelope ID:", event.envelopeId); console.log("PowerForm ID:", event.powerFormId); console.log("Recipient ID:", event.recipientId); });
2. Fixing missing parameters in iframe-based PowerForm returns
It’s super frustrating when the parameters show up in a direct browser tab but vanish in an iframe—here’s how to fix this:
- Check your PowerForm’s return URL settings first:
This is the most common fix. In the DocuSign Admin console, edit your PowerForm and make sure:- Your
Return URLis correctly set to your callback page. - You’ve checked the box labeled "Include envelope information in the return URL" (this is often disabled by default!). Enabling this forces DocuSign to append
envelopeId,powerFormId, andrecipientIdto the return URL, regardless of whether the PowerForm is opened directly or in an iframe.
- Your
- Update your iframe attributes:
Make sure your iframe allows top-level navigation, which helps ensure the redirect carries all parameters properly. Add theallow="top-navigation"attribute to your iframe tag:<iframe id="docusign-signing" src="YOUR_POWERFORM_URL" allow="top-navigation"></iframe> - Manually specify parameter placeholders (if building custom embedded links):
If you’re generating embedded signing URLs via the DocuSign API instead of using the default PowerForm link, you can explicitly define yourreturnUrlwith placeholders that DocuSign will replace with actual values:
This guarantees the parameters are included in the redirect, even in an iframe.{ "returnUrl": "https://your-domain.com/signing-callback?envelopeId={{envelopeId}}&powerFormId={{powerFormId}}&recipientId={{recipientId}}" } - Listen for iframe redirects in the parent page (optional):
If you need to capture the parameters directly in the parent page (instead of relying on the callback page), you can listen for the iframe’sloadevent and extract the parameters from its URL. Just note this only works if your callback page is on the same domain as the parent page to avoid CORS issues:const signingIframe = document.getElementById('docusign-signing'); signingIframe.addEventListener('load', () => { const callbackUrl = new URL(signingIframe.contentWindow.location.href); const envelopeId = callbackUrl.searchParams.get('envelopeId'); const powerFormId = callbackUrl.searchParams.get('powerFormId'); const recipientId = callbackUrl.searchParams.get('recipientId'); // Do something with these values here if (envelopeId) { console.log("Received envelope ID:", envelopeId); } });
内容的提问来源于stack exchange,提问作者user9520811
相关产品推荐
相关产品推荐

