Skip to content

Commit ff6e624

Browse files
scheduled sending and delayed routing
2 parents af3c281 + 80ba8b5 commit ff6e624

File tree

5 files changed

+177
-186
lines changed

5 files changed

+177
-186
lines changed

lib/eSignature/examples/delayedRouting.js

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @file
3-
* Example 035: Creates an envelope that would include two documents and add a signer and cc recipients to be notified via email
3+
* Example 035: Delayed Routing
44
* @author DocuSign
55
*/
66

@@ -35,7 +35,7 @@
3535
};
3636

3737
/**
38-
* Creates an envelope that would include two documents and add a signer and cc recipients to be notified via email
38+
* Creates an envelope with one document, two signers, and includes a delay before routing to the second signer.
3939
* @function
4040
* @param {Object} args object
4141
* @returns {Envelope} An envelope definition
@@ -46,15 +46,16 @@
4646
// args.signer1Email
4747
// args.signer1Name
4848
// args.signer2Email
49-
// args.signer2xName
49+
// args.signer2Name
5050
// args.docPdf
5151
// args.delay
5252

5353

54-
// document 1 (pdf) has tag /sn1/
54+
// document (pdf) has tag /sn1/
5555
//
5656
// The envelope has two recipients.
5757
// recipient 1 - signer
58+
// recipient 2 - signer
5859

5960
let docPdfBytes;
6061
// read files from a local directory
@@ -63,9 +64,9 @@
6364

6465
// create the envelope definition
6566
let env = new docusign.EnvelopeDefinition();
66-
env.emailSubject = "Please sign this document set";
67+
env.emailSubject = "Please sign this document";
6768

68-
// add the documents
69+
// add the document
6970
let doc = new docusign.Document(),
7071
docb64 = Buffer.from(docPdfBytes).toString("base64");
7172
doc.documentBase64 = docb64;
@@ -88,20 +89,22 @@
8889
let signer2 = docusign.Signer.constructFromObject({
8990
email: args.signer2Email,
9091
name: args.signer2Name,
91-
recipientId: "1",
92-
routingOrder: "1",
92+
recipientId: "2",
93+
routingOrder: "2",
9394
});
9495
// routingOrder (lower means earlier) determines the order of deliveries
9596
// to the recipients. Parallel routing order is supported by using the
9697
// same integer as the order for two or more recipients.
9798

9899
// Create a workflow model
99-
// Add the workflow rule that sets the schedule for the envelope to be sent
100+
// Add the workflow rule that sets the delay in hours before the envelope is routed to the second signer
101+
let delayTime = "0." + args.delay.toString() + ":00:00";
100102
const rule = docusign.EnvelopeDelayRuleApiModel.constructFromObject({
101-
delay: args.delay
103+
delay: delayTime
104+
});
105+
const delayedRouting = docusign.DelayedRoutingApiModel.constructFromObject({
106+
rules: [rule]
102107
});
103-
const delayedRouting = docusign.delayedRoutingApiModel();
104-
delayedRouting.rules = [rule]
105108

106109
// Create a workflow model
107110
const workflowStep = docusign.WorkflowStep.constructFromObject({
@@ -116,34 +119,38 @@
116119
});
117120
env.workflow = workflow;
118121

119-
// Create signHere fields (also known as tabs) on the documents,
120-
// We're using anchor (autoPlace) positioning
122+
// Create signHere fields (also known as tabs) on the document,
123+
// We're using anchor (autoPlace) positioning for the signHere1 tab
124+
// and we're using absolute positioning for the signHere2 tab.
121125
//
122126
// The DocuSign platform searches throughout your envelope's
123-
// documents for matching anchor strings. So the
124-
// signHere2 tab will be used in both document 2 and 3 since they
125-
// use the same anchor string for their "signer 1" tabs.
127+
// documents for matching anchor strings.
126128
let signHere1 = docusign.SignHere.constructFromObject({
127-
anchorString: "**signature_1**",
129+
anchorString: "/sn1/",
128130
anchorYOffset: "10",
129131
anchorUnits: "pixels",
130132
anchorXOffset: "20",
131133
}),
132134
signHere2 = docusign.SignHere.constructFromObject({
133-
anchorString: "/sn1/",
134-
anchorYOffset: "10",
135-
anchorUnits: "pixels",
136-
anchorXOffset: "20",
135+
xPosition: "320",
136+
yPosition: "175",
137+
pageNumber: "1",
138+
documentId: "1"
137139
});
138140
// Tabs are set per recipient / signer
139141
let signer1Tabs = docusign.Tabs.constructFromObject({
140-
signHereTabs: [signHere1, signHere2],
142+
signHereTabs: [signHere1],
141143
});
142144
signer1.tabs = signer1Tabs;
143145

146+
let signer2Tabs = docusign.Tabs.constructFromObject({
147+
signHereTabs: [signHere2],
148+
});
149+
signer2.tabs = signer2Tabs;
150+
144151
// Add the recipients to the envelope object
145152
let recipients = docusign.Recipients.constructFromObject({
146-
signers: [signer1]
153+
signers: [signer1, signer2]
147154
});
148155
env.recipients = recipients;
149156

lib/eSignature/examples/scheduledSending.js

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @file
3-
* Example 035: Creates an envelope that would include two documents and add a signer and cc recipients to be notified via email
3+
* Example 035: Scheduled Sending
44
* @author DocuSign
55
*/
66

@@ -35,7 +35,7 @@
3535
};
3636

3737
/**
38-
* Creates an envelope that would include two documents and add a signer and cc recipients to be notified via email
38+
* Creates and schedules an envelope that includes one document and a single signer to be notified via email
3939
* @function
4040
* @param {Object} args object
4141
* @returns {Envelope} An envelope definition
@@ -49,7 +49,7 @@
4949
// args.resumeDate
5050

5151

52-
// document 1 (pdf) has tag /sn1/
52+
// document (pdf) has tag /sn1/
5353
//
5454
// The envelope has a single recipient.
5555
// recipient 1 - signer
@@ -61,9 +61,9 @@
6161

6262
// create the envelope definition
6363
let env = new docusign.EnvelopeDefinition();
64-
env.emailSubject = "Please sign this document set";
64+
env.emailSubject = "Please sign this document";
6565

66-
// add the documents
66+
// add the document
6767
let doc = new docusign.Document(),
6868
docb64 = Buffer.from(docPdfBytes).toString("base64");
6969
doc.documentBase64 = docb64;
@@ -95,36 +95,26 @@
9595
status: "pending",
9696
rules: [rule]
9797
});
98-
const workflowStep = docusign.WorkflowStep();
99-
workflowStep.scheduledSending = scheduledSendingModel;
10098

10199
const workflow = docusign.Workflow.constructFromObject({
102-
workflowSteps: [workflowStep]
100+
scheduledSending: scheduledSendingModel
103101
});
104102
env.workflow = workflow;
105103

106-
// Create signHere fields (also known as tabs) on the documents,
104+
// Create a signHere field (also known as a tab) on the document,
107105
// We're using anchor (autoPlace) positioning
108106
//
109107
// The DocuSign platform searches throughout your envelope's
110-
// documents for matching anchor strings. So the
111-
// signHere2 tab will be used in both document 2 and 3 since they
112-
// use the same anchor string for their "signer 1" tabs.
108+
// documents for matching anchor strings.
113109
let signHere1 = docusign.SignHere.constructFromObject({
114-
anchorString: "**signature_1**",
115-
anchorYOffset: "10",
116-
anchorUnits: "pixels",
117-
anchorXOffset: "20",
118-
}),
119-
signHere2 = docusign.SignHere.constructFromObject({
120110
anchorString: "/sn1/",
121111
anchorYOffset: "10",
122112
anchorUnits: "pixels",
123113
anchorXOffset: "20",
124114
});
125115
// Tabs are set per recipient / signer
126116
let signer1Tabs = docusign.Tabs.constructFromObject({
127-
signHereTabs: [signHere1, signHere2],
117+
signHereTabs: [signHere1],
128118
});
129119
signer1.tabs = signer1Tabs;
130120

views/pages/examples/eg035ScheduledSending.ejs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<div class="form-group">
3131
<label for="signerName">Resume Date</label>
3232
<input type="date" class="form-control" id="resumeDate" name="resumeDate" required />
33+
<small id="dateHelp" class="form-text text-muted">Please choose a date in the future.</small>
3334
</div>
3435
<input type="hidden" name="_csrf" value="<%- csrfToken %>">
3536
<button type="submit" class="btn btn-primary">Submit</button>

views/pages/index.ejs

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,47 @@
55
<div class="jumbotron jumbotron-fluid">
66

77
<table>
8-
<tbody>
9-
<tr>
10-
<td>
11-
<h1 class="display-4">DocuSign Code Launcher: Node.js</h1>
12-
<p class="Xlead">This launcher both demonstrates use of Authorization Code Grant and JWT OAuth flows and includes multiple usage examples for the DocuSign eSignature REST API.</p>
13-
</td>
14-
<td>
15-
<img src="/images/banner-code.png" />
16-
</td>
17-
</tr>
18-
</tbody>
19-
</table>
8+
<tbody>
9+
<tr>
10+
<td>
11+
12+
13+
14+
<% if (locals.dsConfig.multiSourceChooser) { %>
15+
<h1 class="display-4">Welcome</h1>
16+
<p class="Xlead">Run and explore DocuSign code examples with Authorization Code Grant or JWT Grant authentication</p>
17+
<% } else { %>
18+
<h1 class="display-4">Node Launcher</h1>
19+
<% if (examplesApi.examplesApi.isAdminApi) { %>
20+
<p class="Xlead">
21+
Run and explore DocuSign Admin API code examples with Authorization Code Grant or JWT Grant authentication
22+
</p>
23+
<% } else if (examplesApi.examplesApi.isClickApi) { %>
24+
<p class="Xlead">
25+
Run and explore Click API code examples with Authorization Code Grant or JWT Grant authentication
26+
</p>
27+
<% } else if (examplesApi.examplesApi.isRoomsApi) { %>
28+
<p class="Xlead">
29+
Run and explore Rooms API code examples with Authorization Code Grant or JWT Grant authentication
30+
</p>
31+
<% } else if (examplesApi.examplesApi.isMonitorApi) { %>
32+
<p class="Xlead">
33+
Run and explore Monitor API code examples with JWT Grant authentication
34+
</p>
35+
<% } else { %>
36+
<p class="Xlead">
37+
Run and explore eSignature REST API code examples with Authorization Code Grant or JWT Grant authentication
38+
</p>
39+
<% } %>
40+
<% } %>
41+
42+
</td>
43+
<td>
44+
<img src="/images/banner-code.png" />
45+
</td>
46+
</tr>
47+
</tbody>
48+
</table>
2049

2150
</div>
2251
</div>

0 commit comments

Comments
 (0)