Here is my scenario:
In Salesforce, I have an Opportunity that can be related to multiple Opportunity Documents (custom object). There are three Opportunity Documents: Non-Disclosure Agreement, Contract, and Onboarding Policy Agreement. We created Gen templates for each of these.
Each document may have a different person that needs to sign. For example, Bob may need to sign the Non-Disclosure Agreement and Contract while Alice needs to sign the Onboarding Policy Agreement. As such, we have a "Signer" field captured on Onboarding Document.
Lastly, there could be multiple of one document on an Opportunity that needs to be signed. For instance, we may have two copies of a Non-Disclosure Agreement that needs signature for one opportunity.
Our thinking is that we could create an LWC that leverages the apex toolkit to allow a user to, at any point, select one or more Opportunity Documents and then click a button called Generate Envelope. Using the Bob/Alice example above, the LWC (referencing the apex toolkit) would:
- Create an envelope
- See that the signers for all the documents are Bob and Alice, and therefore create a recipient for Bob and a recipient for Alice.
- Generate each document using the corresponding gen template 3a. For each document, grab the Signer and set its signature tag to the appropriate recipient. (ex: Bob is the Signer for Non-Disclosure Agreement, so Bob's recipientId would be set to the signature tag in the Non-Disclosure Agreement. Alice is the Signer for Onboarding Policy Agreement, so Alice's recipientId would be set to the signature tag in the Onboarding Policy Agreement. Bob is the Signer for Contract, so Bob's recipientId would be set to the signature tag in the Contract).
- Redirect user to sender view so they can review everything before actually sending.
Here is what I don't want: I don't want Bob to be two recipients in this scenario. I want Bob to be one recipient that gets tied to the signature tags for two documents so he only gets one email and can provide all his signatures in that one email.
Is this possible using the apex toolkit?
I know this is going to require the apex toolkit because this scenario is much more dynamic than what the Salesforce Docusign package provides out of the box.