[SalesForce] How to use Docusign – create envelope with Lightning

I need to open dsfs__DocuSign_CreateEnvelope from Lightning controller. I tried to use e.force:navigateToURL component:

var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
   "url": "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID=" + cmp.get("v.recordId") +"&DST=" + dst + "&CRL=" + crl + "&CEM=" + cem,
   "isredirect": "true"
});
urlEvent.fire();

but I'm getting error The link you followed isn’t valid. This page requires a CSRF confirmation token. Report this error to your Salesforce administrator.. I found a page with this error on docusign website https://support.docusign.com/en/articles/DocuSign-for-Salesforce-7-0-This-page-requires-a-CSRF-confirmation-token and it says to use {!URLFOR} for Docusing 7.0+, but as I understand it only works for Visualforce pages. How can I do it in lightning?

Best Answer

You can construct the URL from Apex using PageReference class and then return the URL to the Lightning Component controller.

Related Topic