Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
paigesrossi committed Feb 13, 2024
2 parents ec1d2fb + 6a24fe7 commit 82025dc
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ public static class CreateAndEmbedFormService
{
public static WebFormSummaryList GetForms(Client.DocuSignClient docuSignClient, string accountId)
{
//ds-snippet-start:WebForms1Step3
FormManagementApi formManagementApi = new FormManagementApi(docuSignClient);
FormManagementApi.ListFormsOptions listFormsOptions = new FormManagementApi.ListFormsOptions();
listFormsOptions.search = "Web Form Example Template";
return formManagementApi.ListForms(accountId, listFormsOptions);
//ds-snippet-end:WebForms1Step3
}

public static void AddTemplateIdToForm(string fileLocation, string templateId)
Expand Down Expand Up @@ -73,13 +75,11 @@ public static List<EnvelopeTemplate> GetTemplatesByName(
string accountId,
string templateName)
{
//ds-snippet-start:WebForms1Step3
var templatesApi = new TemplatesApi(docuSignClient);
var listTemplateOptions = new TemplatesApi.ListTemplatesOptions();
listTemplateOptions.searchText = templateName;

EnvelopeTemplateResults templates = templatesApi.ListTemplates(accountId, listTemplateOptions);
//ds-snippet-end:WebForms1Step3

return templates.EnvelopeTemplates;
}
Expand Down
51 changes: 40 additions & 11 deletions launcher-csharp/WebForms/Views/CreateAndEmbedForm/Embed.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function loadWebform() {
var instanceToken = '@ViewBag.InstanceToken'.replace(/&#x2B;/g, "+");
const { loadDocuSign } = window.DocuSign
const docusign = await loadDocuSign('@ViewBag.IntegrationKey');
const webFormOptions = {
//Used with the runtime API workflow, for private webforms this is needed to render anything
instanceToken: instanceToken,
Expand All @@ -46,21 +46,50 @@ async function loadWebform() {
minHeight: "1500px",
},
//Controls the auto resize behavior of the iframe
autoResizeHeight: true,
//These values are passed to the iframe URL as query params
tracking: {
"tracking-field": "tracking-value",
},
//These values are passed to the iframe URL as hash params
hidden: {
"hidden-field": "hidden-value",
},
autoResizeHeight: true
};
const webFormWidget = docusign.webforms({
url: "@ViewBag.Url",
options: webFormOptions,
})
});
//Basic milestones in this workflow
webFormWidget.on('ready', (event) => {
// event = { type: 'ready' };
console.log('debug form loaded', event);
});
webFormWidget.on('submitted', (event) => {
// event = { type: 'submitted', envelopeId: 'abcd1234' };
console.log('debug form submitted', event);
});
webFormWidget.on('signingReady', (event) => {
// event = { type: 'submitted', envelopeId: 'abcd1234' };
console.log('debug form signingReady', event);
});
webFormWidget.on('sessionEnd', (event) => {
//There are 3 sessionEnd types sessionTimeout, remoteSigningInitiated, signingResult
// event = { type: 'sessionEnd', sessionEndType: 'sessionTimeout' };
// event = {
// type: 'sessionEnd',
// sessionEndType: 'signingResult',
// signingResultType: 'signing_complete',
// returnUrl: 'bigcorp.com',
// envelopeId: 'abcd1234',
// };
// event = { type: 'sessionEnd', sessionEndType: 'remoteSigningInitiated', envelopeId: 'abcd1234' };
console.log('debug form signingResult', event);
});
//Less commonly used events
webFormWidget.on('userActivity', (event) => {
// event = { type: 'userActivity', activityType: 'click' | 'keydown' };
console.log('debug form userActivity', event);
});
webFormWidget.mount("#docusign");
}
Expand Down
25 changes: 25 additions & 0 deletions launcher-csharp/eSignature/Examples/DocumentGeneration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,31 @@ public static string DocumentGenerationExample(
DocuSignClient docuSignClient = new DocuSignClient(basePath);
docuSignClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);

//ds-snippet-start:eSign42Step2
TemplatesApi templatesApi = new TemplatesApi(docuSignClient);
TemplateSummary template = templatesApi.CreateTemplate(accountId, MakeTemplate());
string templateId = template.TemplateId;
//ds-snippet-end:eSign42Step2

//ds-snippet-start:eSign42Step3
templatesApi.UpdateDocument(accountId, templateId, DefaultId, AddDocumentTemplate(offerDocDocx));
//ds-snippet-end:eSign42Step3

//ds-snippet-start:eSign42Step4
templatesApi.CreateTabs(accountId, templateId, DefaultId, PrepareTabs());
//ds-snippet-end:eSign42Step4

//ds-snippet-start:eSign42Step5
EnvelopesApi envelopesApi = new EnvelopesApi(docuSignClient);
EnvelopeSummary envelope = envelopesApi.CreateEnvelope(accountId, MakeEnvelope(candidateEmail, candidateName, templateId));
string envelopeId = envelope.EnvelopeId;
//ds-snippet-end:eSign42Step5

//ds-snippet-start:eSign42Step6
DocGenFormFieldResponse formFields = envelopesApi.GetEnvelopeDocGenFormFields(accountId, envelope.EnvelopeId);
//ds-snippet-end:eSign42Step6

//ds-snippet-start:eSign42Step7
DocGenFormFieldRequest preparedFormFields = FormFields(
formFields.DocGenFormFields.FirstOrDefault()?.DocumentId,
candidateName,
Expand All @@ -70,18 +82,22 @@ public static string DocumentGenerationExample(
accountId,
envelopeId,
preparedFormFields);
//ds-snippet-end:eSign42Step7

//ds-snippet-start:eSign42Step8
EnvelopeUpdateSummary envelopeWithDocGen = envelopesApi.Update(
accountId,
envelopeId,
new Envelope
{
Status = "sent",
});
//ds-snippet-end:eSign42Step8

return envelopeWithDocGen.EnvelopeId;
}

//ds-snippet-start:eSign42Step2
public static EnvelopeTemplate MakeTemplate()
{
Signer signer = new Signer
Expand All @@ -106,7 +122,9 @@ public static EnvelopeTemplate MakeTemplate()
Status = "created",
};
}
//ds-snippet-end:eSign42Step2

//ds-snippet-start:eSign42Step4
public static TemplateTabs PrepareTabs()
{
SignHere signHere = new SignHere
Expand All @@ -130,7 +148,9 @@ public static TemplateTabs PrepareTabs()
DateSignedTabs = new List<DateSigned> { dateSignedTabs },
};
}
//ds-snippet-end:eSign42Step4

//ds-snippet-start:eSign42Step3
public static EnvelopeDefinition AddDocumentTemplate(string offerDocumentDocx)
{
string documentBase64 = Convert.ToBase64String(System.IO.File.ReadAllBytes(offerDocumentDocx));
Expand All @@ -149,7 +169,9 @@ public static EnvelopeDefinition AddDocumentTemplate(string offerDocumentDocx)
Documents = new List<Document> { document },
};
}
//ds-snippet-end:eSign42Step3

//ds-snippet-start:eSign42Step5
public static EnvelopeDefinition MakeEnvelope(string candidateEmail, string candidateName, string templateId)
{
TemplateRole signer = new TemplateRole
Expand All @@ -166,7 +188,9 @@ public static EnvelopeDefinition MakeEnvelope(string candidateEmail, string cand
TemplateId = templateId,
};
}
//ds-snippet-end:eSign42Step5

//ds-snippet-start:eSign42Step7
public static DocGenFormFieldRequest FormFields(
string documentId,
string candidateName,
Expand Down Expand Up @@ -214,5 +238,6 @@ public static DocGenFormFieldRequest FormFields(
},
};
}
//ds-snippet-end:eSign42Step7
}
}

0 comments on commit 82025dc

Please sign in to comment.