|
1 | 1 | /** |
2 | 2 | * @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 |
4 | 4 | * @author DocuSign |
5 | 5 | */ |
6 | 6 |
|
|
35 | 35 | }; |
36 | 36 |
|
37 | 37 | /** |
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. |
39 | 39 | * @function |
40 | 40 | * @param {Object} args object |
41 | 41 | * @returns {Envelope} An envelope definition |
|
46 | 46 | // args.signer1Email |
47 | 47 | // args.signer1Name |
48 | 48 | // args.signer2Email |
49 | | - // args.signer2xName |
| 49 | + // args.signer2Name |
50 | 50 | // args.docPdf |
51 | 51 | // args.delay |
52 | 52 |
|
53 | 53 |
|
54 | | - // document 1 (pdf) has tag /sn1/ |
| 54 | + // document (pdf) has tag /sn1/ |
55 | 55 | // |
56 | 56 | // The envelope has two recipients. |
57 | 57 | // recipient 1 - signer |
| 58 | + // recipient 2 - signer |
58 | 59 |
|
59 | 60 | let docPdfBytes; |
60 | 61 | // read files from a local directory |
|
63 | 64 |
|
64 | 65 | // create the envelope definition |
65 | 66 | let env = new docusign.EnvelopeDefinition(); |
66 | | - env.emailSubject = "Please sign this document set"; |
| 67 | + env.emailSubject = "Please sign this document"; |
67 | 68 |
|
68 | | - // add the documents |
| 69 | + // add the document |
69 | 70 | let doc = new docusign.Document(), |
70 | 71 | docb64 = Buffer.from(docPdfBytes).toString("base64"); |
71 | 72 | doc.documentBase64 = docb64; |
|
88 | 89 | let signer2 = docusign.Signer.constructFromObject({ |
89 | 90 | email: args.signer2Email, |
90 | 91 | name: args.signer2Name, |
91 | | - recipientId: "1", |
92 | | - routingOrder: "1", |
| 92 | + recipientId: "2", |
| 93 | + routingOrder: "2", |
93 | 94 | }); |
94 | 95 | // routingOrder (lower means earlier) determines the order of deliveries |
95 | 96 | // to the recipients. Parallel routing order is supported by using the |
96 | 97 | // same integer as the order for two or more recipients. |
97 | 98 |
|
98 | 99 | // 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"; |
100 | 102 | const rule = docusign.EnvelopeDelayRuleApiModel.constructFromObject({ |
101 | | - delay: args.delay |
| 103 | + delay: delayTime |
| 104 | + }); |
| 105 | + const delayedRouting = docusign.DelayedRoutingApiModel.constructFromObject({ |
| 106 | + rules: [rule] |
102 | 107 | }); |
103 | | - const delayedRouting = docusign.delayedRoutingApiModel(); |
104 | | - delayedRouting.rules = [rule] |
105 | 108 |
|
106 | 109 | // Create a workflow model |
107 | 110 | const workflowStep = docusign.WorkflowStep.constructFromObject({ |
|
116 | 119 | }); |
117 | 120 | env.workflow = workflow; |
118 | 121 |
|
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. |
121 | 125 | // |
122 | 126 | // 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. |
126 | 128 | let signHere1 = docusign.SignHere.constructFromObject({ |
127 | | - anchorString: "**signature_1**", |
| 129 | + anchorString: "/sn1/", |
128 | 130 | anchorYOffset: "10", |
129 | 131 | anchorUnits: "pixels", |
130 | 132 | anchorXOffset: "20", |
131 | 133 | }), |
132 | 134 | 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" |
137 | 139 | }); |
138 | 140 | // Tabs are set per recipient / signer |
139 | 141 | let signer1Tabs = docusign.Tabs.constructFromObject({ |
140 | | - signHereTabs: [signHere1, signHere2], |
| 142 | + signHereTabs: [signHere1], |
141 | 143 | }); |
142 | 144 | signer1.tabs = signer1Tabs; |
143 | 145 |
|
| 146 | + let signer2Tabs = docusign.Tabs.constructFromObject({ |
| 147 | + signHereTabs: [signHere2], |
| 148 | + }); |
| 149 | + signer2.tabs = signer2Tabs; |
| 150 | + |
144 | 151 | // Add the recipients to the envelope object |
145 | 152 | let recipients = docusign.Recipients.constructFromObject({ |
146 | | - signers: [signer1] |
| 153 | + signers: [signer1, signer2] |
147 | 154 | }); |
148 | 155 | env.recipients = recipients; |
149 | 156 |
|
|
0 commit comments