Reputation: 1
To give a brief overview, I have created a rest endpoint where I accept an Opportunity Id and I create an eSignature Contract on that Opportunity, create a PDF and I also create a URL which will open Docusign and allow the user to sign
The issue is the URL that gets generated is a Salesforce URL and is tied to the auth session from the API call. It's not possible to open this URL in a browser, as you get the error "The link you followed wasn’t valid for your session. Return to the previous page, refresh it, and try again". It seesm this was intended only for use within Salesforce itself, like in a LWC or Aura Component
What I am trying to do now is find a way that will allow me to create a Docusign URL for signing instead of a Salesforce URL so I can return that to the endpoint and they can open the docusign there
In researching this I discovered we have the legacy version of DocuSign eSignature for Salesforce, and the Apex Toolkit (which seemed to have the tools I need to do this) is only available with the newer version
so I installed this on my sandbox and started looking through the methods made available as they seemed like they would do what I need, but it seems the architecture is quite different between legacy DocuSign eSignature for Salesforce and the new one.
I feel like I am going around in circles. I cannot find any documentation on what the differences are between the two versions, The details about the apex toolkit are only useful to a point and some parts are downright frustrating, for example all the templates we were using in legacy were done with Quote Template in Salesforce, but the template Id required for creating an envelope via the toolkit is for the templates on Docusign itself (at least according to the little documentation I can find on the apex toolkit)
so I am back to square one and hoping someone here is using legacy DocuSign eSignature for Salesforce and is able to shine some light on how I can create a docusign URL for an eSignature Contract. It feels like this should be straight forward! the URL I get, which is meant for use in a LWC or similar, is just a redirect to the docusign page. How do I do the middle part and just get the docusign url returned?
I tried looking up how those methods in the apex toolkit work but it's very unclear. for example I can see from the URL I have generated that the docusign class getting referenced is dfds__docusign_createenvelope and I have tried looking at dfsle.EnvelopeService.getEmptyEnvelope. both of these accept a parameter called sourceId. The legacy one accepts the Id of an eSignature Contract, but the apex toolkit one accepts a contact Id?? will the apex toolkit also accept the eSignature Contract? also, the template Id I use with the legacy is the quote template, but in their videos they only talk about the docusign templates. will the apex toolkit accept the quote template id? there is no documentation on this anywhere
Upvotes: 0
Views: 388
Reputation: 14050
You cannot do this without setting up your own web server or without using Salesforce as an intermediary.
Any link not sent by DocuSign will expire very quickly (2-5 minutes) and that is a security feature that cannot be changed.
So what most developers do is generate a link to their web-server, the web-server in turn calls the eSignature API to generate a new link and their redirect the user. The API call usually only take 1-2 seconds and the redirect is not too slow for users to accept (you can also put some text like "contacting DocuSign..." or what not).
If you want to go that route - we have plenty of documentation on embedded signing and it's unrelated to Apex or Salesforce, but you'll need a server.
Upvotes: 0