I am using the Docusign Rest API, through a gem for Rails. I have 2 recipients, and need both of them to sign the document.
It should work like this:
- Generate envelope with borrower(s) info passing to the envelope.
- Display embedded document for signing.
- Return to custom url/action
- If there is another signer, it should
- reload the iframe
- ask for second signers signature, with the same template that was just signed
Instead it breaks when I reloads the iframe for the 2nd signer. It generates the envelope, with my second signer with its unique ID, email etc. However when I then create the recipient view, it returns nil.
How do I get signer 1 to sign, then load it for the second signer right after, with all the custom fields filled both times?
def deliver(signing_borrower)
client = DocusignRest::Client.new
hashData = {
status: 'sent',
template_id: my_id
signers: [
{
embedded: true,
name: signing_borrower.name,
email: signing_borrower_email,
role_name: if (signing_borrower==borrower) then 'Borrower' else 'Co-borrower' end
}
]
}
generate_liabilities
hashData[:signers][0][:tabs] = if (signing_borrower==borrower) then custom_fields else co_borrower_custom_fields end
#if there is a coborrower, add that data to the form as the second signer
if co_borrower
if signing_borrower==co_borrower then opposite_of_signing_borrower = borrower else opposite_of_signing_borrower = co_borrower end
borrower2= {
name: opposite_of_signing_borrower.name,
email: signing_borrower_email(opposite_of_signing_borrower),
role_name: if (opposite_of_signing_borrower==co_borrower) then 'Co-borrower' else 'Borrower' end
}
#add second borrower to hash to generate envelope with all form fields filled
hashData[:signers] << borrower2
hashData[:signers][1][:tabs] = {
textTabs: text_tabs,
checkboxTabs: checkbox_tabs
}
end
response = client.create_envelope_from_template hashData
self.envelope_id = response["envelopeId"]
self.signing_url = DocusignRest::Client.new.get_recipient_view({
envelope_id: self.envelope_id,
name: signing_borrower.name,
email: signing_borrower_email(signing_borrower),
return_url: return_url
})
response
end
The hashData
{:status=>"sent",
:email=>
{:subject=>"Application...",
:body=>"please sign...."},
:template_id=>"XXXX-XXXX-XXXX",
:signers=>
[{:embedded=>true,
:name=>"DAVID L. TESTCASE",
:email=>"email@test.com",
:role_name=>"Borrower",
:tabs=>
{:textTabs=>
[{:tablabel=>"phone",
:name=>"phone",
:value=>"717-717-7171"}]
}
},
{:name=>"MARISOL TESTCASE",
:email=>"email2@test.com",
:role_name=>"Co-borrower",
:tabs=>
{:textTabs=>
[{:tablabel=>"phone",
:name=>"phone",
:value=>"717-717-7171"}]
}
}]}